<body> <h1>s:if标签的用法</h1> <s:set name="price" value="25"></s:set> 价格:<s:property value="#price"/> <p> <s:if test="#price > 20"> 定义的变量price的值是大于20 </s:if> <p> <s:elseif test="#price < 20"> 定义的变量price的值是小于20 </s:elseif> <p> <s:else>定义的变量price的值等于20</s:else> <p> <p> <s:set name="str" value="'新年快乐'"></s:set> 字符串:<s:property value="#str"/> <p> <s:if test="%{#str == '新年快乐'}"> 祝大家2012年,<s:property value="#str"/> </s:if> <p> </body>
if 不等于的使用,变量的使用
<s:iterator value="categories" id='i' begin="0" step="1" status="status">
<s:set name="flag" value="#i.parentId" />
<s:property value="#flag" />
<s:if test="#i.parentId != 1">222</s:if>
</s:iterator>