Reputation: 259
If I use the JSTL forEach loop to display a list of all returned items from my controller, Is there a way to output an index number for each item that is returned in the list?
<c:forEach var="item" items="#{Controller.allItems}" >
<tr><td>{index number here???} : #{item.name}</td></tr>
</c:forEach>
Upvotes: 0
Views: 155
Reputation: 3749
That's what the attribute varStatus is for:
<c:forEach var="item" items="#{Controller.allItems}" varStatus="status" >
<tr><td>${status.index} : #{item.name}</td></tr>
</c:forEach>
VarStatus contains many other Attributes as well:
Upvotes: 3