关键在于<c:forEach>的varStatus属性,具体代码如下: <table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<th>序号</th>
<th>姓名</th>
</tr>
<c:forEach var="student" items="${ students}" varStatus="status">
<tr>
<td>${ status.index + 1}</td>
<td>${ student.name}</td>
</tr>
</c:forEach>
</table> 备注:status.index是从0开始的。
相关文章
- jsp页面forEach循环时实现序号的自增
- jsp jstl表达式 c:forEach 循环输出整数
- JSP页面通过c:forEach标签循环遍历List集合
- [JSP] c:forEach 如何输出序号
- [JSP] c:forEach 如何输出序号 - luotangsha的专栏 - 博客频道 - CSDN.NET
- jsp页面输出序号
- c#---部分;把数组或者结构体存入集合里,然后再从集合中取出之后,输出;foreach既可以用到提取数组重点额数据,也可以提取集合中的数据(前提是集合中的元素是相同数据类型)
- 关于JSP的C标签之forEach循环分隔符
- c:foreach如何输出序号
- [JSP] c:forEach 输出序号 每行自动生成序号