关键在于<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开始的。  

相关文章:

  • 2021-06-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-05
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
相关资源
相似解决方案