在jsp中的案例
<div> <h2>案例1:Map案例</h2> <s:iterator var="entity" value="#{1:'小灰灰',2:'懒羊羊',3:'沸羊羊'}"> <s:property value="#entity.key"/> <s:property value="#entity.value"/> </s:iterator><br><br> <s:iterator value="#{1:'小灰灰',2:'懒羊羊',3:'沸羊羊'}"> <s:property value="key"/> <s:property value="value"/> </s:iterator> </div> <hr color="green"> <div> <h2>案例2:构造List案例 语法:{value1,value2,value3}</h2> <s:iterator value="{'Java','PHP','.NET','3G'}"> <s:property/> </s:iterator><br><br> <s:iterator var="edu" value="{'语文','数学','英语','地理'}"> <s:property value="edu"/> </s:iterator> </div> <hr color="black"> <div> <h2>案例3:单选按钮</h2> <s:radio list="#{'w':'女','m':'男'}" listKey="key" listValue="value" value="'m'"></s:radio><br> <s:radio list="{'女','男'}" value="'女'"></s:radio><br> <s:radio name="sex" list="#{'1':'男','0':'女'}" value="'1'"></s:radio> </div> <hr color="red"> <div> <h2>案例4:多选按钮</h2> <s:checkboxlist name="fav" list="#{1:'唱歌',2:'跳舞',3:'打篮球',4:'游泳'}" listKey="key" listValue="value" value="{1,2,3}"></s:checkboxlist><br> <s:checkbox name="fav" label="瑜伽用品"></s:checkbox> <s:checkbox name="fav" label="户外用品"></s:checkbox> <s:checkbox name="fav" label="游泳用品"></s:checkbox> <s:checkbox name="fav" label="跑步用品"></s:checkbox><br><br> <s:checkboxlist name="fav" list="{'唱歌','跳舞','玩游戏','跑步'}" value="{'玩游戏','跑步'}"></s:checkboxlist> </div> <hr color="purple"> <div> <h2>案例5:下拉列表</h2> <s:select label="课程" name="edus" headerKey="-1" headerValue="选择课程" list="#{'1':'语文','2':'数学','3':'英语','4':'计算机'}" value="Select the course" required="true"/><br><br> <s:select label="课程" name="edus" list="#{'1':'语文','2':'数学','3':'英语','4':'计算机'}" value="{'1'}" required="true"/><br><br> <s:select list="{'Java专业','3G专业','.NET专业','PHP专业'}" label="选择专业" value="'.NET专业'"/><br><br> <s:select name="list" list="{'Java专业','3G专业','.NET专业','PHP专业'}" value="'PHP专业'"></s:select><br><br> <s:select name="map" list="#{'1':'语文','2':'数学','3':'英语','4':'计算机'}" listKey="key" listValue="value" value="2" label="课程"/> </div> <hr color="green"> <div> <h2>案例6:if标签</h2> <s:if test="'Java' is not at {'Java','.NET'}中"> Java in 集合中; </s:if> <s:else> Java 不在集合中。 </s:else> </div> <hr color="blue"> <div> <h2>案例7:set标签</h2> <s:set var="msg" value="'aaa<br/>aaaa'" ></s:set> <s:property value="msg" escape="false"/> </div> <hr color="black"> <div> <h2>案例8:push标签</h2> <s:push value="'abc'"> <s:property/> </s:push> </div> <hr color="red"> <div> <h2>案例9:bean标签</h2> <s:bean name="www.csdn.struts_tag.domain.Users" var="Myusers"> <s:param name="name" value="'张三'"></s:param> <s:param name="pass" value="'zhang123'"></s:param> <s:param name="sex" value="'男'"></s:param> <s:param name="email" value="'[email protected]'"></s:param> aa: <s:property value="name"/> </s:bean> <s:property value="#Myusers.name"/><br> <s:set value="#Myusers" var="user"></s:set> <s:property value="#user.name"/> </div> <hr color="red"> <div> <h2>案例10:iterator标签</h2> <table> <s:iterator var="name" value="{'Java','NET','PHP','3G'}" status="st"> <tr class="<s:property value='#st.even?"even":"odd"'/>"> <td> <s:property value="name"/> </td> </tr> </s:iterator> </table> </div>