티스토리 뷰

JSTL

[JSTL] Core - if tag

A형개발자 2016. 8. 7. 22:23

JSTL Core - if tag

test attribute 에 condition 를 체크하여 c:if tag 의 body content 를 실행한다.

Attributes

Name Dynamic Type Required
test true boolean Yes
var false String No
scope false String No

How to use

<%@ page import="java.util.Calendar"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
	Calendar currentDate = Calendar.getInstance();
	int hour = currentDate.get(Calendar.HOUR_OF_DAY);
	request.setAttribute("hour", hour);
%>
<html>
<head>
	<title>JSTL if tag example</title>
</head>
<body>
<h1>Hello world!</h1>
<c:if test="${hour >= 9 && hour < 18}">
	<P>Body Content => The hour on the my office is <%=currentDate.getTime()%>. I am working.</P>
</c:if>
</body>
</html>  

Result


Description

속성 test에 정의된 condition 에 만족 할 경우 tag body 내의 content가 JSP 내에 보여진다.

Reference


'JSTL' 카테고리의 다른 글

[JSTL] Core :: forEach 태그  (0) 2016.08.10
[JSTL] Core :: choose tag  (0) 2016.08.08
[JSTL] Core :: catch tag  (0) 2016.08.07
[JSTL] Core :: remove tag  (0) 2016.08.04
[JSTL] Core :: set tag  (0) 2016.08.04
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/09   »
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
글 보관함