[JSP] c:forEach 输出序号判断奇偶数作不同处理
2015-03-09 13:52
543 查看
关键在于<c:forEach>的varStatus属性,具体代码如下:
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<th>序号</th>
<th>姓名</th>
</tr>
<c:forEach var="list" items="${list}" varStatus="status">
<tr>
<td>${ status.index + 1}</td>
<td>${ student.name}</td>
</tr>
<tr>
<c:if test="${status.index%2==0}">
这是奇数
</c:if>
<c:if test="${status.index%2!=0}">
这是偶数
</c:if>
</tr>
</c:forEach>
</table>
备注:status.index是从0开始的。
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<th>序号</th>
<th>姓名</th>
</tr>
<c:forEach var="list" items="${list}" varStatus="status">
<tr>
<td>${ status.index + 1}</td>
<td>${ student.name}</td>
</tr>
<tr>
<c:if test="${status.index%2==0}">
这是奇数
</c:if>
<c:if test="${status.index%2!=0}">
这是偶数
</c:if>
</tr>
</c:forEach>
</table>
备注:status.index是从0开始的。
相关文章推荐
- jsp中 c:forEach 如何输出递增序号
- [JSP] c:forEach 如何输出序号
- [JSP] c:forEach 如何输出序号 - luotangsha的专栏 - 博客频道 - CSDN.NET
- [JSP] c:forEach 如何输出序号
- [JSP] c:forEach 输出序号 每行自动生成序号
- jsp: c:foreach 输出序号
- jsp中 c:forEach 如何输出递增序号
- [JSP] c:forEach 如何输出序号
- [JSP] c:forEach 如何输出序号
- [JSP] c:forEach 如何输出序号
- [JSP] c:forEach 如何输出序号
- servlet处理数据库表中所有数据,在jsp页面表格中用jst forEach输出解决办法
- 在vc下和gcc下不同函数名,可使用宏来判断处理
- c:forEach 如何输出序号
- 从键盘中输入十个数判断偶数和奇数,输出平均值。
- jsp中判断的问题(例如不同权限有不同操作,页面相同)
- struts2 if 判断内容选择输出jsp
- 输入任意大小的三个整数,判断其中是否有两个奇数一个偶数。若是,则输出“YES”,不是则输出“NOT” (要求用条件表达式进行判断,不使用if语句)
- c:forEach 如何输出序号
- 在不同语言中关于CheckBox的处理办法(ASP、JSP、PHP)