How c:forEach outputs the serial number

The key lies in the varStatus attribute of <c:forEach>, the specific code is as follows:

<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
    <th>serial number</th>
    <th>Name</th>
</tr>
<c:forEach var="student" items="${ students}" varStatus="status">
<tr>
    <td>${ status.index + 1}</td>
    <td>${ student.name}</td>
</tr>
</c:forEach>
</table>

Note: status.index starts from 0.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326152770&siteId=291194637