웹 프로그래밍 20-1(JSP)-JSTL 시작
프로그래밍 정리/JSP, Servlet, DB(oracle)
2020. 1. 6. 10:22
반응형
웹 프로그래밍 20-1(JSP)-JSTL 시작
-종합
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | //변수 선언 <c:set var="변수명" value="값" target="객체(map, list등..)" property="property="객체(map,list..)의 속성이름(name : 10 => name을 가리킴)" scope="범위" > //변수 출력 <c:out value="출력값" default="기본값"> ex1) <!-- 변수 선언--> <c:set var="num1" value="${ 20}"></c:set><br> <!-- 변수 출력 --> <c:out value="num1" default="${10}"> ex2) <!--map 생성 --> <c:set var="ht" value="<%= new HashMap<String,String>() %>"></c:set> <!-- map에 값 넣음 --> <c:set target="${ht}" property="name" value="hong"></c:set> <!-- map 값 출력 --> <c:out value="${ht.name}" > //변수 제거 <c:remove var="변수명" scope="범위" //예외 처리 <c:catch var="변수명"> //if문 <c:if test="조건문" var="조건 처리 변수명" scope="범위"> ex) <!-- 60보다 같거나 크면 실행 --> <c:if test="${ param.kor >= 60}"> <c:out value="합격입니다."></c:out> </c:if> //for 문 <c:forEach var=변수명 items = "객체(list,map...)" begin = "시작번호" end = "끝번호" step = "증가수" > </c:forEach> ex1) <!-- 1 부터 10까지 1씩 증가 --> <c:forEach var="i" begin="1" end="10" step="1"> ${i}<br> </c:forEach> ex2) <!--map 생성 --> <c:set var="ht" value="<%=new HashMap<String,String>()%>"></c:set> <!-- map에 값 넣음 --> <c:set target="${ht }" property="name" value="hong gil dong"></c:set> <!-- map에 있는 키와 값 하나씩 출력 --> <c:forEach var="i" items="${ht}"> ${i.key} : <c:out value="${i.value }"></c:out><br> </c:forEach> //choose문 <c:choose> <c:when test="조건"> 처리내용 </c:when> <c:when test="조건"> 처리내용 </c:when> <c:otherwise>(switch문 default랑 같음)처리내용</c:otherwise> </c:choose> ex) <c:choose> <c:when test="${jumsu>=90 }"> <c:out value="수입니다."></c:out> </c:when> <c:when test="${jumsu>=80 }"> <c:out value="우입니다."></c:out> </c:when> <c:when test="${jumsu>=70 }"> <c:out value="미입니다."></c:out> </c:when> <c:when test="${jumsu>=60 }"> <c:out value="양입니다."></c:out> </c:when> <c:when test="${jumsu>=50 }"> <c:out value="가입니다."></c:out> </c:when> </c:choose> //tokenizer <c:forTokens var="변수명" items="값" delims="구분문자"> <c:out value="${변수명}"></c:out> </c:forTokens> ex) <c:forTokens var="color" items="red;green;blue;black" delims=";"> <br><c:out value="${color}"></c:out> </c:forTokens> //redirect <c:redirect url="전송할 페이지"> ex) <!-- redirect_response.jsp 페이지로 이동 --> <c:redirect url="redirect_response.jsp"> //redirect - 파라미터 포함 <c:redirect url="전송할 페이지"> <c:param name="파라미터명" value="값"></c:param> </c:redirect> ex) <!-- redirect_response.jsp 페이지로 이동 + 값 포함 --> <c:redirect url="redirect_response.jsp"> <c:param name="name" value="hong gil dong"></c:param> </c:redirect> | cs |
반응형
'프로그래밍 정리 > JSP, Servlet, DB(oracle)' 카테고리의 다른 글
웹 프로그래밍 21(JSP,servlet)-FrontController패턴 (0) | 2020.01.06 |
---|---|
웹 프로그래밍 20-2(JSP)-JSTL 기초, Core를 사용해보자 (0) | 2020.01.06 |
웹 프로그래밍 19-3(JSP)-내장객체(pageScope, requestScope, sessionScope, applicationScope) (0) | 2020.01.06 |
웹 프로그래밍 19-2(JSP)-EL과 빈(bean) (0) | 2020.01.06 |
웹 프로그래밍 19-1(JSP)-EL(Expression Language) (0) | 2020.01.06 |