Here’s the simplest way I’ve found for alternating the background color of rows in JSP/JSTL:
<style type="text/css">
.row0 { background-color:#fff; }
.row1 { background-color:#ececec; }
</style>
<c:forEach items="${myItems}" var="myItem" varStatus="lineInfo">
<tr class="row<c:out value="${lineInfo.index % 2}"/>">
...
</tr>
</c:forEach>
Thanks for the post, just one thing.
In order to get a number from lineInfo, I think you meant this:
<c:out value="${lineInfo.index % 2}"/>
You’re right, good catch! Thanks!