码迷,mamicode.com
首页 > Web开发 > 详细

[JSP] c:forEach 如何输出序号

时间:2016-04-02 18:48:17      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

 1 关键在于<c:forEach>的varStatus属性,具体代码如下:   
 2   
 3 <table width="500" border="0" cellspacing="0" cellpadding="0">  
 4 <tr>  
 5     <th>序号</th>  
 6     <th>姓名</th>  
 7 </tr>  
 8 <c:forEach var="student" items="${ students}" varStatus="status">  
 9 <tr>  
10     <td>${ status.index + 1}</td>  
11     <td>${ student.name}</td>  
12 </tr>  
13 </c:forEach>  
14 </table>  
15   
16 备注:status.index是从0开始的。

 

[JSP] c:forEach 如何输出序号

标签:

原文地址:http://www.cnblogs.com/fujilong/p/5347950.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!