There is a friendship called:
"Accompany me to the grocery store." ”
"Not to go,"
"I ask you."
Go ”
你想起了谁:胖先生?还有人陪你吗?
The JSP standard tag library (JSP Standards tag libraries) is a collection of JSP tags that encapsulates the Common Core functionality of JSP applications.
It appears because people start to focus on the software 分层设计
and do not want to appear in the JSP page JAVA 逻辑代码
. At the same time, because 自定义标签
of the difficulty of development, it is not conducive to the standardization of technology, thus produced a JSTL.
JSTL 和 EL 的结合
, basically can make the page no more <% %>
code.
JSTL Standard Tag Library can be divided into five categories: [In fact, generally used three kinds of]
Core Tag Library
A total of 14, from the functional can be divided into 4 categories. Reference method:
个人喜欢引入方式:
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
可以测试上节的JSP标签方式
还有一种引入方式为:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Expression control
This is what we use most often.
label |
Description |
<c:out > |
Used to display data, just like <%= %> , the difference is that the <c:out> label can access the property directly through the . operator |
<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. |
Process Control
label |
Description |
<c:if > |
As we used in the general program if , but there is no else operation, disguised implementation |
<c:choose > |
itself only as <c:when> <c:otherwise> a parent tag, equivalent to a switch label |
<c:when> |
<c:choose> To determine if the condition is established. |
<c:otherwise> |
<c:choose> Sub-label, followed by the <c:when> label, <c:when> is executed when the label is judged to be false |
Cycle [emphasis]
label |
Description |
<c:forEach> |
Base iteration tags, which accept multiple collection types,默默的回忆,有哪些重点? |
<c:forTokens> |
Separates the content and iterates the output according to the specified delimiter.怎么说,真的很实用的功能! |
URL Action
label |
Description |
<c:import> |
Retrieves an absolute or relative URL and then adds its contents to 暴露给页面 替换 the JSP's动态包含 |
<c:redirect> |
Use optional query parameters to create a URL |
<c:url > |
Redirect to a new URL |
<c:param > |
Used to pass parameters to a page that contains or redirects |
<c:import>
Think about what the result would be if you worked with a JSP filter? Please do the experiment!
Formatting tag Libraries
Used to format and output text, date, time, number, only the most common two tags are described here, the reference method:
个人喜欢引入方式:
<%@taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
可以测试上节的JSP标签方式
还有一种引入方式为:
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
Formatting numbers
label |
Description |
<fmt:formatNumber> |
Formats a number using the specified format or precision |
涉及到钱的时候,不要使用float/double,还有使用银行家四舍五入方式
Formatted date
label |
Description |
<fmt:formatDate> |
Formats the date and time with the specified style or pattern |
yyyy mm MM dd H h ss 都是含义,默背一下!
Function Tag Library
Most are generic string handlers that are used in conjunction with an EL expression. Reference method:
个人喜欢引入方式:
<%@taglib prefix="fn" uri="http://java.sun.com/jstl/functions_rt" %>
可以测试上节的JSP标签方式
还有一种引入方式为:
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
label |
Description |
<fmt:formatNumber> |
Formats a number using the specified format or precision |
涉及到钱的时候,不要使用float/double,还有使用银行家四舍五入方式
Formatted date
label |
Description |
Fn:contains () |
Tests whether the input string contains the specified substring, such as:${fn:contains("ABC", "a")} |
Fn:containsignorecase () |
Tests whether the input string contains the specified substring and is case insensitive, such as:${fn:containsIgnoreCase("ABC", "a")} |
Fn:endswith () |
Tests whether the input string ends with the specified suffix, such as:${fn:endsWith("ABC", "bc")} |
Fn:startswith () |
Tests whether the input string starts with the specified prefix, such as:${fn:startsWith("ABC", "ab")} |
Fn:escapexml () |
Used to convert all special characters to character entity codes. It contains only a string parameter and returns a string of type value |
Fn:indexof () |
Used to get the starting position where the substring matches the source string, and returns "1" if the substring does not match the contents of the source string. It includes string and substring two parameters, and returns the result as an int type.${fn:indexOf("ABCD","aBC")} |
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:substring () |
Returns a subset of the strings, such as:${fn:substring("ABC","1","2")} |
Fn:substringafter () |
Returns a subset of the string after the specified substring, such as:${fn:substringAfter("ABCD","BC")} |
Fn:substringbefore () |
Returns a subset of the string before the specified substring, such as:${fn:substringBefore("ABC","1","2")} |
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 |
SQL Tag LibraryI won'tXML Tag LibraryI will not refer to
C Label Introduction
FMT Label Introduction
functions忘记写了,日后补充上,百度也有一堆
From for notes (Wiz)
[Application] Third JSP standard tag library (JSTL) Summary