테이블형 상품 리스트

기여·2024년 7월 4일
0

소소한 개발팁

목록 보기
48/103

(shopSel: select all from shop ^^)

결과:

예제:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div align="center">
 
<h1>shopSel</h1>

<table width="700">
    <thead>
        <tr align="center">
        </tr>
    </thead>
    <c:if test="${li.size() == 0}">
        <tr class="tr_color">
            <td colspan="3" align="center">레코드가 존재 하지 않습니다.</td>
        </tr>
    </c:if>
    <c:if test="${li.size() != 0}">
        <c:set var="idx" value="0" />
        <c:forEach var="m" items="${li}" varStatus="status">
            <c:if test="${status.index % 3 == 0}">
                <tr class="tr_color">
            </c:if>
            <td align="center">
                <a href="shopView.do?pid=${m.pid}">
                    <img src="${path}/shop/img/${m.pimgStr}" width="70">
                </a>
            </td>
            <c:if test="${status.index % 3 == 2 || status.index == li.size() - 1}">
                <c:forEach var="i" begin="${status.index - status.index % 3}" end="${status.index}" step="1">
                    <c:if test="${i % 3 == 2 || i == li.size() - 1}">
                        </tr>
                    </c:if>
                </c:forEach>
                <tr class="tr_color">
                    <c:forEach var="i" begin="${status.index - status.index % 3}" end="${status.index}" step="1">
                        <td align="center">
                            <a href="shopView.do?pid=${li[i].pid}">
                                ${li[i].pname}
                            </a>
                        </td>
                    </c:forEach>
                </tr>
                <tr class="tr_color">
                    <c:forEach var="i" begin="${status.index - status.index % 3}" end="${status.index}" step="1">
                        <td align="center">${li[i].pprice}</td>
                    </c:forEach>
                </tr>
            </c:if>
        </c:forEach>
        <c:if test="${li.size() % 3 != 0}">
            <c:forEach var="i" begin="${li.size() - li.size() % 3}" end="${li.size() - 1}" step="1">
                <c:if test="${i == li.size() - 1}">
                    </tr>
                </c:if>
            </c:forEach>
        </c:if>
    </c:if>
</table>

</div>

예시 이미지 출처: 쿠팡

profile
기기 좋아하는 여자

0개의 댓글