Last active
March 3, 2016 08:29
-
-
Save Crydust/ce926e3aff0a723b6799 to your computer and use it in GitHub Desktop.
show items in columns table jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<c:if test="${not empty items}"> | |
<c:set var="itemColumns" value="3" /> | |
<table border="1"> | |
<tr> | |
<c:forEach items="${items}" var="item" varStatus="itemStatus"> | |
<td><c:out value="${item}" /></td> | |
<c:if test="${itemStatus.index % itemColumns eq itemColumns - 1}"></tr><tr></c:if> | |
</c:forEach> | |
<c:if test="${fn:length(items) % itemColumns gt 0}"> | |
<td colspan="${itemColumns - (fn:length(items) % itemColumns)}"> </td> | |
</c:if> | |
</tr> | |
</table> | |
</c:if> | |
<c:if test="${not empty items}"> | |
<c:set var="itemColumns" value="3" /> | |
<table border="1"> | |
<c:forEach items="${items}" var="item" varStatus="itemStatus"> | |
<c:if test="${itemStatus.index % itemColumns eq 0"><tr></c:if> | |
<td><c:out value="${item}" /></td> | |
<c:if test="${itemStatus.last and (fn:length(items) % itemColumns gt 0)}"> | |
<td colspan="${itemColumns - (fn:length(items) % itemColumns)}"> </td> | |
</c:if> | |
<c:if test="${itemStatus.last or (itemStatus.index % itemColumns eq itemColumns - 1)}"></tr></c:if> | |
</c:forEach> | |
</table> | |
</c:if> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment