JSTL 흐름제어1
<%@ page contentType="text/html; charset=EUC-KR"%>
<%@ page import="com.member.Member" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
<c:if test="true">
무조건 실행 됩니다.<br>
</c:if>
<c:if test="${param.name == 'Jimmy'}">
파라미터 name의 값이 ${param.name}입니다.<br>
</c:if>
<c:if test="${param.age > 20}">
파라미터 age 의 값이 20 이상입니다.<br>
</c:if>
</body>
</html>
JSTL 흐름제어2
<%@ page contentType="text/html; charset=EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
<c:choose>
<c:when test="${param.name == 'Jimmy'}">
당신의 이름은 Jimmy입니다.<br>
</c:when>
<c:when test="${param.age == 25}">
당신의 나이는 25세입니다.<br>
</c:when>
<c:otherwise>
당신은 누구입니까?
</c:otherwise>
</c:choose>
</body>
</html>
JSTL 흐름제어3
<%@ page contentType="text/html; charset=EUC-KR" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<c:forEach var="i" begin="1" end="10" step="1">
<c:set var="s" value="${s + i}" />
</c:forEach>
${s}
</body>
</html>
JSTL 흐름제어4
<%@ page contentType="text/html; charset=EUC-KR" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<c:set var="arr" value="<%=new int[] { 1, 2, 3, 4, 5 }%>" />
<table border=1>
<tr><th>배열원소</th><th>반복횟수</th><th>배열첨자</th> </tr>
<c:forEach var="a" items="${arr}" begin="0" end="4" varStatus="status">
<tr>
<td>${a}(${status.current})</td>
<td>${status.count}</td>
<td>${status.index}</td>
</tr>
</c:forEach>
</table>
</body>
</html>
JSTL 흐름제어5
<%@ page contentType="text/html; charset=EUC-KR" %>
<%@ page import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("name", "Jimmy");
map.put("today", new Date());
map.put("phone", "010-1111-2222");
%>
<html>
<body>
<c:set var="map" value="<%= map %>" />
<c:forEach var="m" items="${map}" >
${m.key} = ${m.value}<br>
</c:forEach>
</body>
</html>
JSTL 흐름제어6
<%@ page contentType="text/html; charset=EUC-KR" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<c:import url="https://www.naver.com" >
</c:import>
</body>
</html>
JSTL 흐름제어7
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
<c:url value="https://www.google.com/search" var="google">
<c:param name="query" value="거북선" />
</c:url>
<c:redirect url="${google}">
</c:redirect>
</body>
</html>
JSTL 흐름제어8
<%@ page contentType="text/html; charset=EUC-KR" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<%
String contents = "<h1>안녕하세요<br>태그라이브러리의사용법입니다</h1>";
%>
<c:out value="<%= contents %>" escapeXml="true" /><br>
<c:out value="<%= contents %>" escapeXml="false" />
</body>
</html>
JSTL 흐름제어9
<%@ page contentType="text/html; charset=EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
<c:catch var="ex">
<%
int a = 0, b = 2;
b = b / a;
%>
</c:catch>
<c:if test="${ex != null}">
다음과 같은 예외가 발생하였습니다.<br>
${ex}
</c:if>
</body>
</html>
세상을 링크하라!!! 모든 링크를 한 자리에...
링크닷컴: https://linkdotcom.mycafe24.com/
유용한 링크, 링크닷컴 #무료 #링크사이트 #링크사이트
컴퓨터 및 일반 유용한 링크들을 모아 놓았습니다. 지금 바로 확인하세요!
linkdotcom.mycafe24.com
'웹프로그래밍 > JSP' 카테고리의 다른 글
JDBC DB연결 (0) | 2024.06.08 |
---|---|
JSTL 표현언어 함수 (0) | 2024.06.08 |
JSTL 변수처리 (0) | 2024.06.08 |
표현언어와 자바빈 (0) | 2024.06.08 |
param 내장객체 (0) | 2024.06.08 |