天天看点

struts标签bean:cookie,bean:write,logic:page,logic:present,logic:iterate使用实例

jsp椤甸??ndex.jsp锛?

<%@page contentType="text/html;charset=gb2312" language="java"%>

<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>

<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>

<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>

<html>

<head><title>struts test</title></head>

<body> ? <bean:cookie id="jSession" name="userInfo" value="11111"/>

? <!-- ?跺????绛鹃??杩?缁?瀹???age浣??ㄥ??涓???灞??т娇?ㄨ?ュ??-->

? 杩?涓?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> -