[JSP] c:forEach 如何输出序号 - luotangsha的专栏 - 博客频道 - CSDN.NET
- 关键在于<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开始的。
作者:少帅
出处:少帅的博客--http://www.cnblogs.com/wang3680
您的支持是对博主最大的鼓励,感谢您的认真阅读。
本文版权归作者所有,欢迎转载,但请保留该声明。
 支付宝
支付宝  微信
微信
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号