I would like to alternate row color for each row, I know how to alternate row color using varStatus in a forEach loop. However now, I’ve a nested loop.
<c:forEach var="aPermission" items="${Permissions}" varStatus="loop1">
<c:forEach var="anIpRange" items="${aPermission.ipRanges}" varStatus="loop2">
<tr class="${loop2.index % 2 == 0 ? 'row0' : 'row1'}"> [...]
</c:forEach>
</c:forEach>
The code above is using only ‘loop2’ varStatus, and is only an approximation. How to solve the problem? I’ve to introduce my count variable or there are better ways?
Simply use a dedicated counter: