在jsp頁面中為表格添加各行變色的方法
<c:forEach var="student" items="${ students}" varStatus="status">
<c:if test=”${status.index % 2 == 0}”>
<tr class = "even"> --偶數行
........
</tr>
</c:if>
<c:if test=”${status.index % 2 == 1}”>
<tr class = "odd"> --奇數行
........
</tr>
</c:if>
</c:forEach>
然后:
寫兩個類樣式就好了 如:
<style type="text/css">
.even { background : white;}
.odd { background : blue;}
</style>