JSP如何实现数据自增

在JSP页面中使用c标签可以实现数据的自增

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

猜你喜欢

转载自blog.csdn.net/qq_41035779/article/details/81450502