develog

[java] JSTL 본문

Dev/Java

[java] JSTL

냐옴 2012. 11. 14. 10:26

JSTL (Java Standard Tag Library)

  • Core Tags
  • Formatting Tags
  • SQL Tags
  • XML Tags
  • JSTL Functions

Core Tags

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:out>
<c:set>
<c:remove>
<c:catch>
<c:if>
<c:choose>
<c:when>
<c:otherwise>
<c:import>
<c:forEach>
<c:forTokens>
<c:param>
<c:redirect>
<c:url>

Formatting Tags

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<fmt:formatNumber>
<fmt:parseNumber>
<fmt:formatDate>
<fmt:parseDate>
<fmt:bundle>
<fmt:setLocale>
<fmt:setBundle>
<fmt:timeZone>
<fmt:setTimeZone>
<fmt:message>
<fmt:requestEncoding>

SQL Tags

<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>

<sql:setDateSource>
<sql:query>
<sql:update>
<sql:param>
<sql:dateParam>
<sql:transaction>

XML Tags

<%@ taglib prefix="x" uri="http://java.sun.com/jps/jstl/xml" %>

<x:out>
<x:parse>
<x:set>
<x:if>
<x:forEach>
<x:choose>
<x:when>
<x:otherwise>
<x:transform>
<x:param>

JSTL Functions

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

fn:contains()
fn:containsIgnoreCase()
fn:endsWith()
fn:escapeXml()
fn:indexOf()
fn:join()
fn:length()
fn:replace()
fn:split()
fn:startsWith()
fn:substring()
fn:substringAfter()
fn:substringBefore()
fn:toLowerCase()
fn:toUpperCase()
fn:trim()

Examples

<!-- c:import -->
<c:import url="/common/top.do">
    <c:param name="SHOW_BACK">N</c:param>
</c:import>
<!-- c:if -->
<c:if test = "${salary > 2000}">
</c:if>
<!-- c:forEach -->
<c:forEach items="${userList}" var="item">
    <span>${item.userName}</span>
</c:forEach>
<!-- c:choose -->
case1: 
<c:choose>
    <c:when test="${true && true}">
        all true
    </c:when>
    <c:otherwise>
        not all true
    </c:otherwise>
</c:choose>
<br>

case2:
<c:choose>
    <c:when test="${true || false}">
        some true
    </c:when>
    <c:otherwise>
        not some true
    </c:otherwise>
</c:choose>
<br>

case3:
<c:choose>
    <c:when test="${true && false}">
        all true
    </c:when>
    <c:otherwise>
        not all true
    </c:otherwise>
</c:choose>
<br>

<!--
case1: all true
case2: some true
case3: not all true
-->
<!-- c:choose -->
<c:set var="age" value="20"/>

case1:
<c:choose>
    <c:when test="${age == '20'}">
        age is 20
    </c:when>
    <c:otherwise>
        age is not 20
    </c:otherwise>
</c:choose>
<br>

case2:
<c:choose>
    <c:when test="${age != '20'}">
        age is 20
    </c:when>
    <c:otherwise>
        age is not 20
    </c:otherwise>
</c:choose>
<br>

<!--
case1: age is 20
case2: age is not 20
-->

 

 

http://www.tutorialspoint.com/jsp/jsp_standard_tag_library.htm 

 

JSP - Standard Tag Library (JSTL) Tutorial - Tutorialspoint

JSP - Standard Tag Library (JSTL) Tutorial In this chapter, we will understand the different tags in JSP. The JavaServer Pages Standard Tag Library (JSTL) is a collection of useful JSP tags which encapsulates the core functionality common to many JSP appli

www.tutorialspoint.com

 

'Dev > Java' 카테고리의 다른 글

Spring AOP  (0) 2012.11.24
[java] JSP  (0) 2012.11.14
Primitive Variable  (0) 2012.11.12
Primitive Variable, Wrapper Class  (0) 2012.11.12
spring version 확인  (0) 2012.11.08
Comments