http://blog.csdn.net/zlxdream815/article/details/25723981
在使用foreach标签之前,需要在JSP中导入标签
<table align="center" width="98%" border="0" cellspacing="1" cellpadding="0" class="resulttable">
<tr>
<th width="18%">卡种类型</th>
<th width="82%">卡种等级</th>
</tr>
<c:if test="${ empty command.cardList}">
<tr><td align="center" colspan="10" class="oddbgc" >无记录</td>
</tr>
</c:if>
<c:if test="${ not empty command.cardList}">
<c:forEach var="bean" items="${ command.cardList}" varStatus="s">
<c:if test="${bean.dataLevel=='1'}">
<tr>
<td align="left" class="<c:choose ><c:when test='${s.index%2 ==0}'>oddbgc</c:when><c:otherwise>evenbgc</c:otherwise></c:choose>">
<c:out value="${bean.cardName}"/>
</td>
<td align="left" class="<c:choose ><c:when test='${s.index%2 ==0}'>oddbgc</c:when><c:otherwise>evenbgc</c:otherwise></c:choose>">
<c:forEach var="childbean" items="${ command.cardList}" varStatus="sr">
<c:if test="${bean.cardCode eq childbean.parentCardCode}">
<c:out value="${childbean.cardName}"/>
</c:if>
</c:forEach>
</td>
</tr>
</c:if>
</c:forEach>
</c:if>
</table>
jsp页面itertor或forEach循环输出list:
JSP遍历后台传过来的List(总结的比较好):
三种方法:使用jstl标签
使用jsp内嵌Java代码遍历list(在后台把list放到session中)
使用struts标签