상세 컨텐츠

본문 제목

JSTL <c:if> <c:choose> <c:when> <c:otherwise>

JSP

by kwanghyup 2019. 11. 14. 16:00

본문

<c:if>

<c:if test="조건"> 
 몸체 
</c:if>
  	<c:set var="i" value="20"/>
  	<c:if test="${i>10 }">
  		${i} > 10 
  	</c:if>

<c:choose> <c:when> <c:otherwise>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> c:if, c:choose, c:when , c:otherwise </title>
</head>
<body>
<form action="tutorial.jsp">
	<input type="text" name="parameter"/>
	<input type="submit" value="전송">
</form>	
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> c:if, c:choose, c:when , c:otherwise </title>
</head>
<body>
	<c:choose>
		<c:when test="${param.parameter > 10 }">
		  10 보다 큼   
		</c:when> 	 
		<c:when test="${param.parameter < 10 }">
		 10 보다 작음 
		</c:when>
		<c:otherwise>
		 10 과 같음 
		</c:otherwise>
	</c:choose>
</body>
</html>

 

관련글 더보기

댓글 영역