<c:forEach >中如何显示序号

来源:互联网 发布:分类信息系统源码 编辑:程序博客网 时间:2024/05/17 22:10
关键在于<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开始的。

0 0