关键在于<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开始的。
使用<c:forEach>显示列表
本文介绍如何利用JSP中的<c:forEach>标签结合varStatus属性来遍历并显示列表数据,通过具体示例展示了如何为列表项设置序号。
845

被折叠的 条评论
为什么被折叠?



