📄 0034.htm
字号:
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">执行结果</SPAN></P></TD></TR>
<TR>
<TD
style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=140>
<P class=MsoNormal><SPAN lang=EN-US>getRequest</SPAN></P></TD>
<TD
style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: medium none; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"
vAlign=top width=211>
<P class=MsoNormal><SPAN
lang=EN-US>Javax.servlet.jsp.PageContext</SPAN></P></TD>
<TD
style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: medium none; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"
vAlign=top width=203>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回当前</SPAN><SPAN
lang=EN-US>Request</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象</SPAN></P></TD></TR>
<TR>
<TD
style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=140>
<P class=MsoNormal><SPAN
lang=EN-US>getParameterNames</SPAN></P></TD>
<TD
style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: medium none; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"
vAlign=top width=211>
<P class=MsoNormal><EM><SPAN lang=EN-US
style="FONT-STYLE: normal">javax.servlet.ServletRequest</SPAN></EM><I><SPAN
lang=EN-US><O:P> </O:P></SPAN></I></P></TD>
<TD
style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: medium none; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"
vAlign=top width=203>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回当前</SPAN><SPAN
lang=EN-US>Request</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象参数名</SPAN></P></TD></TR>
<TR>
<TD
style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; mso-border-top-alt: solid windowtext .5pt"
vAlign=top width=140>
<P class=MsoNormal><SPAN
lang=EN-US>getParameterValues</SPAN></P></TD>
<TD
style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: medium none; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"
vAlign=top width=211>
<P class=MsoNormal><EM><SPAN lang=EN-US
style="FONT-STYLE: normal">javax.servlet.ServletRequest</SPAN></EM><I><SPAN
lang=EN-US><O:P> </O:P></SPAN></I></P></TD>
<TD
style="BORDER-BOTTOM: windowtext 0.5pt solid; BORDER-LEFT: medium none; BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: medium none; PADDING-BOTTOM: 0cm; PADDING-LEFT: 5.4pt; PADDING-RIGHT: 5.4pt; PADDING-TOP: 0cm; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt"
vAlign=top width=203>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回当前</SPAN><SPAN
lang=EN-US>Request</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象参数值</SPAN></P></TD></TR></TBODY></TABLE>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">你将会发现其他方法包括</SPAN><SPAN
lang=EN-US>ServletRequest</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,</SPAN><SPAN
lang=EN-US>HttpServletRequest</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或者其他任何</SPAN><SPAN
lang=EN-US>ServletRequest</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的子集。</SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">引擎经常在</SPAN><SPAN
lang=EN-US>scenes</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">之后使用</SPAN><SPAN
lang=EN-US>Request</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象,即使你没有明确地在</SPAN><SPAN
lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件中调用。</SPAN></P>
<H4>从<SPAN lang=EN-US>Bean中调数据到JSP页面</SPAN></H4>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一旦用户的数据被传到</SPAN><SPAN
lang=EN-US>Bean</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,你就想重新得到数据,然后在</SPAN><SPAN
lang=EN-US>JSP</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">面页中显示出来。想达到这一步,你就得用到</SPAN> <jsp:getProperty></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">标签。传</SPAN><SPAN
lang=EN-US>Bean</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">名和属性名:</SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><h1>Hello,
<jsp:getProperty name="mybean"
property="username"/>!</SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US><jsp:useBean>,
<jsp:setProperty>, </SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN> <jsp:getProperty></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">标签必须相配,举个例子:</SPAN></P>
<P class=MsoNormal><STRONG><SPAN
lang=EN-US>hellouser.jsp:</SPAN></STRONG><B> <BR></SPAN></B><SPAN lang=EN-US><jsp:useBean
id=<STRONG>"mybean"</STRONG> scope="session"
class="hello.NameHandler" /><BR><jsp:setProperty
name=<STRONG>"mybean"</STRONG> property="*"
/><BR><STRONG>response.jsp:</STRONG><B><BR></B><h1>Hello,
<jsp:getProperty name=<STRONG>"mybean"</STRONG>
property="username"/>!</SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在这个例子里,标签被放在两个文件中,但是指定的名字都是相同的,如果不同的话,那么系统会返回一个错误信息。</SPAN></P>
<H4>如何运行例子</H4>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">我用的是UNIX主机,如果你用</SPAN><SPAN
lang=EN-US>windows</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,那么改相应的路径即可。</SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">创建路径</SPAN> ../jswdk-1.0/examples/jsp/tutorial/hellouser.</SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">把文件</SPAN><SPAN
lang=EN-US>background.gif, duke.waving.gif, dukebanner.html,
hellousr.jsp</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN
lang=EN-US>response.jsp</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">文件放进去。</SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">创建一个目录,</SPAN> ../jswdk-1.0/examples/WEB-INF/jsp/beans/hello</SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">把文件</SPAN><SPAN
lang=EN-US>NameHandler.java</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN
lang=EN-US>NameHandler.class</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">放进去。</SPAN></P>
<P class=MsoNormal><SPAN lang=EN-US>cd../jswdk-1.0</SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">然后</SPAN><SPAN
lang=EN-US>startserver</SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">打开浏览器</SPAN> <A
href="../../计算机名+8080/examples/jsp/tutorial/hellouser/hellouser.jsp">http://<SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">计算机名</SPAN>:8080/examples/jsp/tutorial/hellouser/hellouser.jsp</A></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下课</SPAN></P>
</table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -