c:forEach 如何输出序号


关键在于<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开始的。status.count是从1开始的。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM