아래의 이미지와 같은 조건으로 출력하는 요구가 들어온다면.. 







앞 글과 같이 Controller 에서 "resultList" 로 넘겼다고 가정하고...




<c:set var="i" value="0" />

<c:set var="j" value="3" />


<table name="phoneNumList" border= "1">

    <colgroup>

        <col width="150px" />

        <col width="150px" />

    </colgroup>

    <thead>

        <tr>

            <td style="font-weight: bold;">이름</td>

            <td style="font-weight: bold;">전화번호</td>

        </tr>

    </thead>

    <tbody>

        <c:forEach items="${resultList}" var="List">

            <c:if test="${i%j == 0 }">

                <tr>

            </c:if>

                    <td>${List.name}</td>

                    <td>${List.phoneNum}</td>

            <c:if test="${i%j == j-1 }">

                </tr>

            </c:if>

            <c:set var="i" value="${i+1 }" />

        </c:forEach>

    </tbody>

</table>




물론 최상단에 


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



'뒤죽박죽 머리속' 카테고리의 다른 글

insert-update 구분해서 한줄로  (0) 2016.11.03
javascript 새 창 띄우기  (0) 2016.11.01
List 출력 (일반 게시판)  (0) 2016.11.01
jsp 중복 submit 방지  (0) 2016.10.31
List 형식의 Form 필드 합계  (0) 2016.10.31

+ Recent posts