jsp页面中对表格实现隔行变色方法

在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>
posted @ 2017-03-13 11:13  香吧香  阅读(3539)  评论(0编辑  收藏  举报