<c:forEach items="${ test.numbers }" var="num">

	<c:forEach items="${ num.vec }" var="vec">

	<td>${ vec }</td>

	</c:forEach>

</c:forEach>

스프링 Controller에서 Model에 배열 데이터를 담아서 View로 전달한다면

View에서는 jstl forEach 구문을 이용해서 접근할 수 있다.

 

<c:forEach items="${ test.numbers }" var="num">

	<td>${ num }</td>



</c:forEach>

 

물론 이중구문을 이용해 배열안의 배열까지 접근이 가능하다.

 

 

forEach 구문을 사용안하고 배열 중 한 요소만을 출력하고자 한다면 다음과 같이 작성하면된다.

	<c:out value="${ test.num[1] }" />

num배열에서 2번째 요소가 출력된다.

 

배열 사이즈를 알고 싶을때는 다음과 같이 작성한다.

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

	<c:out value="${fn:length(test.num)}" />

+ Recent posts