日期:2014-05-18  浏览次数:20630 次

大家来帮我解决下。。。
<table border="1" width="80%">
  <tr>
  <c:forEach var="i" items="${requestScope.list}">
  <td width="25%">${i.id}</td>
  <c:if test="${i.id%4==0}">
  </tr>
  </c:if>
  </c:forEach>
  </tr>
</table>

我从数据库中取出ID号存在request中,然后取出来,我要每行4个后换个行,那我是用${i.id%4==0}
我数据库中id是自动增长的,如果我不用id的话要如何来判断换行。。。谢谢大家。。额。。

------解决方案--------------------

<c:foreach var="i" items="${requestScope.list}" varStatus="status">
<c:if test="${status.count%4==0}"> 

</c:if> 

</foreach>
加上这个属性,然后,就可以在中间使用${status.count}这个就是从1开始计算你的记录的
你判断这个是否被4整除就OK了

这样就搞定哒