我想要一个从数据库中获取条目的表。我有所有的工作。我需要做的就是在列中添加了四个条目后,我希望它下拉一行并继续前进,直到数据库中的所有条目都已添加到表中。
这是我目前所拥有的:
<table cellspacing="0" cellpadding="3px">
<c:forEach var="car" begin="0" items="${requestScope.carList}" varStatus="status">
<tr>
<td><a href='Home.jsp'><img src="images/${car.licence}.jpg" width="240px" height="250"/></a></td>
</tr>
<tr>
<td> Licence:${car.licence}, Model:${car.model}, Make:${car.make} and Colour:${car.colour}</td>
</tr>
</c:forEach>
</table>
这只会将所有图像打印成一行。我需要做一个循环或每四张图片放一行的东西。就像是 c:当测试=“${status.index % 4 == 0}” 特 /c:什么时候
最佳答案
有点疯狂的猜测:
<table cellspacing="0" cellpadding="3px">
<c:forEach var="car" begin="0" items="${requestScope.carList}" varStatus="status">
<c:when test="${status.index % 4 == 0}">
<tr>
</c:when>
<td><table><tr><td><a href='Home.jsp'><img src="images/${car.licence}.jpg" width="240px" height="250"/></a></td></tr>
<tr><td> Licence:${car.licence}, Model:${car.model}, Make:${car.make} and Colour:${car.colour}</td></tr></table></td>
<c:when test="${status.index % 4 == 3}">
</tr>
</c:when>
</c:forEach>
</table>
基本上,测试它是否是一组四项中的第一个条目 - 如果是,则开始一个新行。如果它是四个一组中的第四个,则关闭该行。如果它是最后一个条目并且该条目不能被 4 除,您还需要关闭该行。
关于javascript - 当在表格中输入了四个图像时,在 HTML 中删除一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21610874/