關鍵在於<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>