<table class="table table-bordered" width="100%" cellspacing="0">
<tbody>
<c:set var="cnt" value="0" />
<c:forEach items="${list}" var="product">
<c:choose>
<c:when test="${cnt % 3 == 0}"> <!-- cnt%3=0 일 때 -->
<tr>
<td>
${product.p_code}
<img src="/resources/product/${product.p_code}.jpg" width="200">
</td>
</c:when>
<c:when test="${cnt % 3 == 2}"> <!-- cnt%3=2 일 때 -->
<td>
<img src="/resources/product/${product.p_code}.jpg" width="200">
</td>
</tr>
</c:when>
<c:otherwise> <!-- 이도저도 아닐 때 -->
<td>
<img src="/resources/product/${product.p_code}.jpg" width="200">
</td>
</c:otherwise>
</c:choose>
<c:set var="cnt" value="${cnt+1}" /> <!-- cnt=cnt+1 -->
</c:forEach>
<!--
<c:forEach items="${list}" var="product"> var안바꾸면 data안불러와짐
<tr>
<td>${product.p_code}</td>
<td><a href="/product/view?p_code=${product.p_code}">${product.p_name}</a></td>
<td>${product.p_price}</td>
<td><img src="/resources/product/${product.p_code}.jpg" height="70"></td>
<td><fmt:formatDate pattern="yyyy-MM-dd" value="${product.p_rdate}"/></td>
<td><fmt:formatDate pattern="yyyy-MM-dd" value="${product.p_udate}"/></td>
</tr>
</c:forEach>
-->
</tbody>
</table>
댓글