문서의 이전 판입니다!
※ 대/소문자 구분 없음
※ 파스칼 표기법 (Pascal Case) 지향
' For For 변수 = 시작값 To 끝값 구문 Next ' For For 변수 = 시작값 To 끝값 Step 증감값 구문 Next ' For Each For Each 변수 In 객체 구문 Next ' Do While Do While 조건식 구문 Loop ' Do Do 구문 Loop While 조건식 ' Do Until (역조건문) Do Until 조건식 구문 Loop ' Do (역조건문) Do 구문 Loop Until 조건식 ' Exit Exit For Exit Do
// for
for (초기화식; 조건식; 증감식) {
구문;
}
// for
for (변수 : 객체) {
구문;
}
// while
while (조건식) {
구문;
}
// do ~ while
do {
구문;
} while (조건식);
// label, continue, break
loop1:
for (초기화식; 조건식; 증감식) {
if (조건식) {
continue loop1;
}
loop2:
for (초기화식; 조건식; 증감식) {
if (조건식) {
break loop2;
}
}
}
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- forEach -->
<c:forEach var="변수" begin="시작값" end="끝값">
${변수}
</c:forEach>
<c:forEach var="변수" begin="시작값" end="끝값" step="증감값">
${변수}
</c:forEach>
<c:forEach var="변수" items="${객체}">
${변수}
</c:forEach>
<!-- forTokens -->
<c:forTokens var="변수" items="영화,만화,도서" delims=",">
${변수}
</c:forTokens>
<!-- varStatus -->
<c:forEach var="변수" items="${객체}" varStatus="status">
${status.current} <!-- 현재 아이템 -->
${status.index} <!-- 현재 인덱스 (0부터 시작) -->
${status.count} <!-- 현재 카운트 (1부터 시작) -->
${status.first} <!-- 처음인지 여부 (true/false) -->
${status.last} <!-- 마지막인지 여부 (true/false) -->
${status.begin} <!-- 시작값 -->
${status.end} <!-- 끝값 -->
${status.step} <!-- 증감값 -->
</c:forEach>
// for
for (초기화식; 조건식; 증감식) {
구문;
}
// for ~ in
for (변수 in 객체) {
구문;
}
// for ~ of
for (변수 of 객체) {
구문;
}
// while
while (조건식) {
구문;
}
// do ~ while
do {
구문;
} while (조건식);
// label, continue, break
loop1:
for (초기화식; 조건식; 증감식) {
if (조건식) {
continue loop1;
}
loop2:
for (초기화식; 조건식; 증감식) {
if (조건식) {
break loop2;
}
}
}
# for
for ((초기화식; 조건식; 증감식))
do
구문
done
# for
for 변수 in {시작값..끝값}
do
구문
done
# for
for 변수 in {시작값..끝값..증감값}
do
구문
done
# for
for 변수 in 범위
do
구문
done
# while
while [ 조건식 ]
do
구문
done
# until (역조건문)
until [ 조건식 ]
do
구문
done
# continue, break
continue
break