10.27
条件标签:
if choose
//if
<c:set var="num1" value="1"></c:set> <c:set var="num2" value="2"></c:set> <c:if test="${num1>num2}">ok</c:if> <c:if test="${num1<num2}">fail</c:if>
<hr/>
//choose <c:choose> <c:when test="${num1>num2}">ok</c:when> <c:otherwise>fail</c:otherwise> </c:choose>
迭代标签:forEach
<%
List<String> list=new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c");
list.add("d");
list.add("e");
list.add("f");
list.add("g");
list.add("h");
list.add("i");
request.setAttribute("list",list);
%>
<c:forEach items="${list}" var="str" begin="2" end="3" step="2" varStatus="sta">
${sta.count}、${str}<br/>
</c:forEach>
运行结果:
begin:c、d、e、f、g、h、i
end:a、b、c、d
step:a、c、e、g、i
varStatus:${sta.index}下标从0开始、 ${sta.count}从1开始