티스토리 뷰
JSTL Core - if tag
test attribute 에 condition 를 체크하여 c:if tag 의 body content 를 실행한다.
Attributes
| Name | Dynamic | Decription | Type | Required |
|---|---|---|---|---|
| test | true | The test condition that determines whether or not the body content should be processed. | boolean | Yes |
| var | false | Name of the exported scoped variable for the resulting value of the test condition. The type of the scoped variable is Boolean. | String | No |
| scope | false | Scope for var. | 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
링크
TAG
- InputStreamReader
- remove
- forToken
- 자바
- InputStreamWriter
- isDirectory
- choose
- FileInputStream
- foreach
- 임시파일
- IF
- Rowcount
- IO
- BufferedWriter
- Set
- select
- syntax
- highlight.js
- FOUND_ROW
- java
- reflection
- file
- catch
- JSP
- 파일
- jstl
- Field
- BufferedReader
- 소스코드
- 라이브아카데미
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
글 보관함