I want to use the count from the JSTL forEach loop, but my code doesnt seem to work.
<c:forEach items="${loopableObject}" var="theObject" varStatus="theCount">
<div id="divIDNo${theCount}">
</div>
</c:forEach>
produces
<div id="divIDNojavax.servlet.jsp.jstl.core.LoopTagSupport$1Status@5570e2" >
The variable set by
varStatusis aLoopTagStatusobject, not an int. Use:To clarify:
${theCount.index}starts counting at0unless you’ve set thebeginattribute${theCount.count}starts counting at1