WEB

[JSTL] 사용방법

도정우 2016. 12. 1. 13:10

반복문

1. foreach


샘플 데이터

{

data : [

{key = testkey1, key2 = testkey3}, 

{key = testkey2, key2 = testkey4}

]

}



데이터 출력방법

<c:forEach items="${data}" var="list">

<p>${list.key}</p>

<p>${list.key2}</p>

</c:forEach>




인덱스 사용방법



<c:forEach items="${data}" var="list" varStatus="status">

<p>${list.key}</p>

<p>${list.key2}</p>

<p>${status.count} 번째 인덱스</p>

</c:forEach>





참고


current getCurrent() 현재 반복 라운드 아이템

index getIndex() 현재 반복 라운드의 제로 기반(zero-based) 인덱스

count getCount() 현재 반복 라운드의 1 기반(one-based) 인덱스

first isFirst() 현재 라운드가 반복을 통한 첫 번째 패스임을 나타내는 플래그

last isLast() 반복현재 라운드가 반복을 통한 마지막 패스임을 나타내는 플래그

begin getBegin() begin 애트리뷰트의 값

end getEnd() end 애트리뷰트의 값

step getStep() step 애트리뷰트의 값