Web Language/Script L

[JSTL] core 반복 태그 - forEach, forTokens

해피마루 2022. 6. 18. 20:01
728x90
반응형

 

 forEach
     - 객체 전체에 걸쳐 반복 실행할 때 사용   
          <c:forEach   items="반복할 객체명"
                              begin="시작값"
                              end="종료값"
                              step="증가값"
                              var="변수명"
                              varStatus="별도의 변수" />

 forTokens
     - 문자열을 주어진 구분자(delimiter)로 분할
          <c:forTokens items="반복할 객체명"
                              delims="구분자"
                              begin="반복할 시작값"
                              end="반목 마지막값"
                              step="증가값"
                              var="변수명"
                              varStatus="별도의 변수"
    ex)
          <c:forTokens var="color" items="빨강,주황.노란.초록,파랑,남색.보라" delims=",.">
               color : <c:out value="${color}" /><br>
          </c:forTokens>

728x90
반응형