티스토리 뷰

Function tags

Function 라이브러리를 상단에 꼭 추가해주도록 하자!
JSTL Core tags도 사용하고 싶으면 그 라이브러리도 꼭 추가해줘야 한다.

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
  • fn:contains(): 특정 문자열이 있는지를 검사한다, true/false 값을 리턴한다
  • fn:containsIgnoreCase()
  • fn:endsWith()
  • fn:escapeXml()
  • fn:indexOf()
  • fn:trim() : 빈칸을 지워주는 역할을 한다
  • fn:startsWith()
  • fn:split()
  • fn:toLowerCase()

참고로 c:out을 굳이 쓰지 않고 ${ } 만으로도 출력할 수 있다

<c:set var="string" value="Welcome to JSP Programming"/>  
${fn:toLowerCase("HELLO,")}  
${fn:toLowerCase(string)}  
  • fn:toUpperCase()
  • fn:substringBefore()
  • fn:length()
  • fn:replace()
String fn:replace(String input, String search_for, String replace_with)  

Formatting tags

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"  %>  
  • fmt:parseNumber
  • fmt:timeZone
  • fmt:formatNumber
    • type= currency, number, percent
    • groupingUsed, maxIntegerDigits, maxFractionDigits, maxIntegerDigits, pattern 등...
  • fmt:parseDate
  • fmt:bundle : class처럼 사용
  • fmt:setTimeZone
  • fmt:setBundle
  • fmt:message
  • fmt:formatDate

XML tags

 <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>  
  • x:out
  • x:parse
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
 <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>  
  
<html>  
<head>  
 <title>XML Tags</title>  
</head>  
<body>  
<h2>Vegetable Information:</h2>  
<c:set var="vegetable">  
<vegetables>  
    <vegetable>  
      <name>onion</name>  
      <price>40/kg</price>  
    </vegetable>  
 <vegetable>  
      <name>Potato</name>  
      <price>30/kg</price>  
    </vegetable>  
 <vegetable>  
      <name>Tomato</name>  
      <price>90/kg</price>  
    </vegetable>  
</vegetables>  
</c:set>  
<x:parse xml="${vegetable}" var="output"/>  
<b>Name of the vegetable is</b>:  
<x:out select="$output/vegetables/vegetable[1]/name" /><br>  
<b>Price of the Potato is</b>:  
<x:out select="$output/vegetables/vegetable[2]/price" />  
</body>  
</html> 

출력 결과:

Vegetable Information:
Name of the vegetable is: onion

Price of the Potato is: 30/kg
  • x:set
  • x:choose
  • x:when
  • x:otherwise
  • x:if
  • x:transform: used in an XML documnet to provide XLS(Extensible Stylesheet Language)
  • x:param: used to set the parameter in the XSLT style sheet

SQL tags

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>  
  • sql:setDataSource
  • sql:query
  • sql:update
  • sql:param
  • sql:dateParam
  • sql:transaction

'JSP > JSTL' 카테고리의 다른 글

JSTL 사용법  (0) 2020.08.05