2015第37周一struts2 jstl 标签

复制代码
<c:if test="${user.password == 'hello'}">     
<c:choose>         
<c:when test="${user.age <= 18}">             
<font color="blue"/>         
</c:when>         
<c:when test="${user.age <= 30 && user.age > 18}">             
<font color="red"/>         
</c:when>         
<c:otherwise>             
<font color="green"/>         
</c:otherwise>     
</c:choose>
</c:if>
复制代码

STRUTS2:

复制代码
<s:if test="#user.age <= 18">     
<font color="blue"/>
</s:if>
<s:elseif test="#user.age <= 30 && user.age > 18">     
<font color="red"/>
</s:elseif> 
<s:else>    
<font color="green"/>
</s:else>
复制代码

6. 迭代标签

JSTL:   

复制代码
<c:forEach var="user" items="${users}">     
<c:out value="${user.userName}"/>
</c:forEach><!-- 迭代固定次数 -->
<c:forEach var="i" begin="1" end="10" step="3">    
<c:out value="${i}"/>
</c:forEach><!-- 这种循环相当于for(int i=1; i<10; i++), 其中step是指迭代的步长,默认为1. -->
原文地址:https://www.cnblogs.com/doit8791/p/4787742.html