本文共 1687 字,大约阅读时间需要 5 分钟。
jsp页面index.jsp:
< contentType="text/html;charset=gb2312" language="java"%> < uri="/WEB-INF/struts-html.tld" prefix="html"%> < uri="/WEB-INF/struts-bean.tld" prefix="bean"%> < uri="/WEB-INF/struts-logic.tld" prefix="logic"%> <html> <head><title>struts test</title></head> <body> <bean:cookie id="jSession" name="userInfo" value="11111"/> <!-- 其它标签通过绑定到page作用域中的属性使用该值 --> 这个cookie的名称是<bean:write name="jSession" property="name"/>,值为<bean:write name="jSession" property="value"/>。<br/> <!-- JSP脚本通过scripting变量使用该值 --> <% String name = jSession.getName(); String value = jSession.getValue(); out.println("这个cookie的名称是"+name+",值为"+value+"。<br/>"); %> <html:form action="login" method="post"> <html:text property="user" value="hello" /><html:errors property="user"/> <html:text property="pwd" /><html:errors property="pwd" /> <br> <html:errors /> <html:checkbox property="cb" value="1">fe</html:checkbox><html:errors property="cb" /> <html:submit value="提交" /> </html:form> <bean:page id="te" property="request" /> <%=te.getContentType()%><br> string attribute: <logic:present name="tdstr"> <bean:write name="tdstr" /><br /> </logic:present> other object attribute: <logic:present name="tdobj"> <bean:write name="tdobj" property="user"/><br /> </logic:present> iterate other Array object attribute:<br /> <logic:present name="sarr"> <logic:iterate id="sobj" name="sarr"> <bean:write name="sobj" /><br /> </logic:iterate> </logic:present> iterate other Hashtable object attribute:<br /> <logic:present name="htobj"> <logic:iterate id="hto" name="htobj"> <bean:write name="hto" property="key" />:<bean:write name="hto" property="value" /><br /> </logic:iterate> </logic:present> </body> </html> 转载地址:http://xclmi.baihongyu.com/