Core tags
The core tag is the most commonly used jstl tag. The syntax for referencing the core tag library is as follows:
<%@ taglib Prefix="C" uri= "http://java.sun.com/jsp/jstl/core" %>
label |
Description |
<c:out> |
Used to display data in JSPs, like <%= ... > |
<c:set> |
For saving data |
<c:remove> |
Used to delete data |
<c:catch> |
To handle the abnormal condition that caused the error, and to store the error message. |
<c:if> |
Same as we do in the general procedure |
<c:choose> |
Only as a parent tag for <c:when> and <c:otherwise> |
<c:when> |
<c:choose> Sub-tags to determine if conditions are true |
<c:otherwise> |
<c:choose> Sub-label, followed by the <c:when> tag, when the <c:when> tag is judged to be false when it is executed |
<c:import> |
Retrieves an absolute or relative URL, and then exposes its contents to the page |
<c:forEach> |
Base iteration tags, accepting multiple collection types |
<c:forTokens> |
Separates content and iterates output according to the specified delimiter |
<c:param> |
Used to pass parameters to a page that contains or redirects |
<c:redirect> |
Redirect to a new URL. |
<c:url> |
Use optional query parameters to create a URL |
Formatting labels
The JSTL format label is used to format and output text, date, time, and number. The syntax for referencing the formatting tag library is as follows:
<%@ taglib prefix = "FMT" Uri=%>
label |
Description |
<fmt:formatNumber> |
Formats a number using the specified format or precision |
<fmt:parseNumber> |
Parse a string representing a number, currency, or percentage |
<fmt:formatDate> |
Formats the date and time with the specified style or pattern |
<fmt:parseDate> |
Parse a string that represents a date or time |
<fmt:bundle> |
Binding Resources |
<fmt:setLocale> |
Designated Area |
<fmt:setBundle> |
Binding Resources |
<fmt:timeZone> |
Specify time zone |
<fmt:setTimeZone> |
Specify time zone |
<fmt:message> |
Display Resource profile information |
<fmt:requestEncoding> |
Set the character encoding of the request |
SQL tags
The JSTL SQL Tag Library provides a label that interacts with a relational database (Oracle,mysql,sql server, and so on). The syntax for referencing the SQL tag library is as follows:
<%@ taglib Prefix="sql" uri= "http://java.sun.com/jsp/jstl/sql" %>
label |
Description |
<sql:setDataSource> |
Specify the data source |
<sql:query> |
Run the SQL query statement |
<sql:update> |
To run the SQL UPDATE statement |
<sql:param> |
To set a parameter in an SQL statement to a specified value |
<sql:dateParam> |
Sets the date parameter in the SQL statement to the specified Java.util.Date object value |
<sql:transaction> |
Provide nested database behavior elements in a shared database connection, and run all statements as a single transaction |
XML tags
The JSTL XML tag library provides a label for creating and manipulating XML documents. The syntax for referencing the XML tag library is as follows:
<%@ taglib Prefix="x" uri="Http://java.sun.com/jsp/jstl/xml" %>
Before using XML tags, you must copy the XML and XPath related packages to your <tomcat installation directory >\lib:
label |
Description |
<x:out> |
Similar to <%=, but only for XPath expressions |
<x:parse> |
Parsing XML Data |
<x:set> |
To set an XPath expression |
<x:if> |
Evaluates the XPath expression, if true, executes the contents of the ontology, otherwise skips the ontology |
<x:forEach> |
Iterate over a node in an XML document |
<x:choose> |
Parent tags for <x:when> and <x:otherwise> |
<x:when> |
<x:choose> Sub-tags for conditional judgment |
<x:otherwise> |
<x:choose> Sub-label, executed when <x:when> evaluates to False |
<x:transform> |
To apply an XSL transformation to an XML document |
<x:param> |
Work with <x:transform> to set up XSL style sheets |
Jstl function
Jstl contains a series of standard functions, most of which are general-purpose string processing functions. The syntax for referencing the JSTL function library is as follows:
<%@ taglib Prefix="FN" uri="Http://java.sun.com/jsp/jstl/functions" %>
function |
Description |
Fn:contains () |
Tests whether the input string contains the specified substring |
Fn:containsignorecase () |
Tests whether the input string contains the specified substring, is case insensitive |
Fn:endswith () |
Tests whether the input string ends with the specified suffix |
Fn:escapexml () |
Skipping characters that can be tagged as xml |
Fn:indexof () |
Returns the position of the specified string where it appears in the input string |
Fn:join () |
The elements in the array are composited into a string and then output |
Fn:length () |
return string length |
Fn:replace () |
Replaces the specified position in the input string with the specified string and returns |
Fn:split () |
Separates the string with the specified delimiter and then composes a substring array and returns |
Fn:startswith () |
Tests whether the input string starts with the specified prefix |
Fn:substring () |
Returns a subset of a string |
Fn:substringafter () |
Returns a subset of a string after a specified substring |
Fn:substringbefore () |
Returns a subset of the string before the specified substring |
Fn:tolowercase () |
Convert characters in a string to lowercase |
Fn:touppercase () |
To capitalize characters in a string |
Fn:trim () |
Remove the first white space character |
Original link: http://www.runoob.com/jsp/jsp-jstl.html
Jstl Tag Library