<!-- 从fn的tld中,可以清楚的看到具体的方法声明(function-signature)及示例(example),方法声明处可以看到参数类型及返回值类型。看懂这个tld就可以自己写自定义标签了 -->
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>JSTL 1.1 functions library</description>
<display-name>JSTL functions</display-name>
<tlib-version>1.1</tlib-version>
<short-name>fn</short-name>
<uri>http://java.sun.com/jsp/jstl/functions</uri>
<function>
<description>
Tests if an input string contains the specified substring.
</description>
<name>contains</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean contains(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:contains(name, searchString)}">
</example>
</function>
<function>
<description>
Tests if an input string contains the specified substring in a case insensitive way.
</description>
<name>containsIgnoreCase</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean containsIgnoreCase(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:containsIgnoreCase(name, searchString)}">
</example>
</function>
<function>
<description>
Tests if an input string ends with the specified suffix.
</description>
<name>endsWith</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean endsWith(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:endsWith(filename, ".txt")}">
</example>
</function>
<function>
<description>
Escapes characters that could be interpreted as XML markup.
</description>
<name>escapeXml</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String escapeXml(java.lang.String)</function-signature>
<example>
${fn:escapeXml(param:info)}
</example>
</function>
<function>
<description>
Returns the index withing a string of the first occurrence of a specified substring.
</description>
<name>indexOf</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>int indexOf(java.lang.String, java.lang.String)</function-signature>
<example>
${fn:indexOf(name, "-")}
</example>
</function>
<function>
<description>
Joins all elements of an array into a string.
</description>
<name>join</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String join(java.lang.String[], java.lang.String)</function-signature>
<example>
${fn:join(array, ";")}
</example>
</function>
<function>
<description>
Returns the number of items in a collection, or the number of characters in a string.
</description>
<name>length</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>int length(java.lang.Object)</function-signature>
<example>
You have ${fn:length(shoppingCart.products)} in your shopping cart.
</example>
</function>
<function>
<description>
Returns a string resulting from replacing in an input string all occurrences
of a "before" string into an "after" substring.
</description>
<name>replace</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String replace(java.lang.String, java.lang.String, java.lang.String)</function-signature>
<example>
${fn:replace(text, "-", "•")}
</example>
</function>
<function>
<description>
Splits a string into an array of substrings.
</description>
<name>split</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String[] split(java.lang.String, java.lang.String)</function-signature>
<example>
${fn:split(customerNames, ";")}
</example>
</function>
<function>
<description>
Tests if an input string starts with the specified prefix.
</description>
<name>startsWith</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean startsWith(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:startsWith(product.id, "100-")}">
</example>
</function>
<function>
<description>
Returns a subset of a string.
</description>
<name>substring</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String substring(java.lang.String, int, int)</function-signature>
<example>
P.O. Box: ${fn:substring(zip, 6, -1)}
</example>
</function>
<function>
<description>
Returns a subset of a string following a specific substring.
</description>
<name>substringAfter</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String substringAfter(java.lang.String, java.lang.String)</function-signature>
<example>
P.O. Box: ${fn:substringAfter(zip, "-")}
</example>
</function>
<function>
<description>
Returns a subset of a string before a specific substring.
</description>
<name>substringBefore</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String substringBefore(java.lang.String, java.lang.String)</function-signature>
<example>
Zip (without P.O. Box): ${fn:substringBefore(zip, "-")}
</example>
</function>
<function>
<description>
Converts all of the characters of a string to lower case.
</description>
<name>toLowerCase</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String toLowerCase(java.lang.String)</function-signature>
<example>
Product name: ${fn:toLowerCase(product.name)}
</example>
</function>
<function>
<description>
Converts all of the characters of a string to upper case.
</description>
<name>toUpperCase</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String toUpperCase(java.lang.String)</function-signature>
<example>
Product name: ${fn:UpperCase(product.name)}
</example>
</function>
<function>
<description>
Removes white spaces from both ends of a string.
</description>
<name>trim</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String trim(java.lang.String)</function-signature>
<example>
Name: ${fn:trim(name)}
</example>
</function>
</taglib>
<!-- 函数说明 -->
函数名函数说明使用举例fn:contains判断字符串是否包含另外一个字符串<c:if test="${fn:contains(name, searchString)}">fn:containsIgnoreCase判断字符串是否包含另外一个字符串(大小写无关)<c:if test="${fn:containsIgnoreCase(name, searchString)}">fn:endsWith判断字符串是否以另外字符串结束<c:if test="${fn:endsWith(filename, ".txt")}">fn:escapeXml把一些字符转成XML表示,例如<字符应该转为<${fn:escapeXml(param:info)}fn:indexOf子字符串在母字符串中出现的位置${fn:indexOf(name, "-")}fn:join将数组中的数据联合成一个新字符串,并使用指定字符格开${fn:join(array, ";")}fn:length获取字符串的长度,或者数组的大小${fn:length(shoppingCart.products)}fn:replace替换字符串中指定的字符${fn:replace(text, "-", "•")}fn:split把字符串按照指定字符切分${fn:split(customerNames, ";")}fn:startsWith判断字符串是否以某个子串开始<c:if test="${fn:startsWith(product.id, "100-")}">fn:substring获取子串${fn:substring(zip, 6, -1)}fn:substringAfter
获取从某个字符所在位置开始的子串
${fn:substringAfter(zip, "-")}fn:substringBefore获取从开始到某个字符所在位置的子串${fn:substringBefore(zip, "-")}fn:toLowerCase转为小写${fn.toLowerCase(product.name)}fn:toUpperCase转为大写字符${fn.UpperCase(product.name)}fn:trim去除字符串前后的空格${fn.trim(name)}
<!-- 函数说明 -->
函数
描述
fn:contains(string, substring)
如果参数string中包含参数substring,返回true
fn:containsIgnoreCase(string, substring)
如果参数string中包含参数substring(忽略大小写),返回true
fn:endsWith(string, suffix)
如果参数 string 以参数suffix结尾,返回true
fn:escapeXml(string)
将有特殊意义的XML (和HTML)转换为对应的XML character entity code,并返回
fn:indexOf(string, substring)
返回参数substring在参数string中第一次出现的位置
fn:join(array, separator)
将一个给定的数组array用给定的间隔符separator串在一起,组成一个新的字符串并返回。
fn:length(item)
返回参数item中包含元素的数量。参数Item类型是数组、collection或者String。如果是String类型,返回值是String中的字符数。
fn:replace(string, before, after)
返回一个String对象。用参数after字符串替换参数string中所有出现参数before字符串的地方,并返回替换后的结果
fn:split(string, separator)
返回一个数组,以参数separator 为分割符分割参数string,分割后的每一部分就是数组的一个元素
fn:startsWith(string, prefix)
如果参数string以参数prefix开头,返回true
fn:substring(string, begin, end)
返回参数string部分字符串, 从参数begin开始到参数end位置,包括end位置的字符
fn:substringAfter(string, substring)
返回参数substring在参数string中后面的那一部分字符串
fn:substringBefore(string, substring)
返回参数substring在参数string中前面的那一部分字符串
fn:toLowerCase(string)
将参数string所有的字符变为小写,并将其返回
fn:toUpperCase(string)
将参数string所有的字符变为大写,并将其返回
fn:trim(string)
去除参数string 首尾的空格,并将其返回
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>JSTL 1.1 functions library</description>
<display-name>JSTL functions</display-name>
<tlib-version>1.1</tlib-version>
<short-name>fn</short-name>
<uri>http://java.sun.com/jsp/jstl/functions</uri>
<function>
<description>
Tests if an input string contains the specified substring.
</description>
<name>contains</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean contains(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:contains(name, searchString)}">
</example>
</function>
<function>
<description>
Tests if an input string contains the specified substring in a case insensitive way.
</description>
<name>containsIgnoreCase</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean containsIgnoreCase(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:containsIgnoreCase(name, searchString)}">
</example>
</function>
<function>
<description>
Tests if an input string ends with the specified suffix.
</description>
<name>endsWith</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean endsWith(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:endsWith(filename, ".txt")}">
</example>
</function>
<function>
<description>
Escapes characters that could be interpreted as XML markup.
</description>
<name>escapeXml</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String escapeXml(java.lang.String)</function-signature>
<example>
${fn:escapeXml(param:info)}
</example>
</function>
<function>
<description>
Returns the index withing a string of the first occurrence of a specified substring.
</description>
<name>indexOf</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>int indexOf(java.lang.String, java.lang.String)</function-signature>
<example>
${fn:indexOf(name, "-")}
</example>
</function>
<function>
<description>
Joins all elements of an array into a string.
</description>
<name>join</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String join(java.lang.String[], java.lang.String)</function-signature>
<example>
${fn:join(array, ";")}
</example>
</function>
<function>
<description>
Returns the number of items in a collection, or the number of characters in a string.
</description>
<name>length</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>int length(java.lang.Object)</function-signature>
<example>
You have ${fn:length(shoppingCart.products)} in your shopping cart.
</example>
</function>
<function>
<description>
Returns a string resulting from replacing in an input string all occurrences
of a "before" string into an "after" substring.
</description>
<name>replace</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String replace(java.lang.String, java.lang.String, java.lang.String)</function-signature>
<example>
${fn:replace(text, "-", "•")}
</example>
</function>
<function>
<description>
Splits a string into an array of substrings.
</description>
<name>split</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String[] split(java.lang.String, java.lang.String)</function-signature>
<example>
${fn:split(customerNames, ";")}
</example>
</function>
<function>
<description>
Tests if an input string starts with the specified prefix.
</description>
<name>startsWith</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>boolean startsWith(java.lang.String, java.lang.String)</function-signature>
<example>
<c:if test="${fn:startsWith(product.id, "100-")}">
</example>
</function>
<function>
<description>
Returns a subset of a string.
</description>
<name>substring</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String substring(java.lang.String, int, int)</function-signature>
<example>
P.O. Box: ${fn:substring(zip, 6, -1)}
</example>
</function>
<function>
<description>
Returns a subset of a string following a specific substring.
</description>
<name>substringAfter</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String substringAfter(java.lang.String, java.lang.String)</function-signature>
<example>
P.O. Box: ${fn:substringAfter(zip, "-")}
</example>
</function>
<function>
<description>
Returns a subset of a string before a specific substring.
</description>
<name>substringBefore</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String substringBefore(java.lang.String, java.lang.String)</function-signature>
<example>
Zip (without P.O. Box): ${fn:substringBefore(zip, "-")}
</example>
</function>
<function>
<description>
Converts all of the characters of a string to lower case.
</description>
<name>toLowerCase</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String toLowerCase(java.lang.String)</function-signature>
<example>
Product name: ${fn:toLowerCase(product.name)}
</example>
</function>
<function>
<description>
Converts all of the characters of a string to upper case.
</description>
<name>toUpperCase</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String toUpperCase(java.lang.String)</function-signature>
<example>
Product name: ${fn:UpperCase(product.name)}
</example>
</function>
<function>
<description>
Removes white spaces from both ends of a string.
</description>
<name>trim</name>
<function-class>org.apache.taglibs.standard.functions.Functions</function-class>
<function-signature>java.lang.String trim(java.lang.String)</function-signature>
<example>
Name: ${fn:trim(name)}
</example>
</function>
</taglib>
<!-- 函数说明 -->
函数名函数说明使用举例fn:contains判断字符串是否包含另外一个字符串<c:if test="${fn:contains(name, searchString)}">fn:containsIgnoreCase判断字符串是否包含另外一个字符串(大小写无关)<c:if test="${fn:containsIgnoreCase(name, searchString)}">fn:endsWith判断字符串是否以另外字符串结束<c:if test="${fn:endsWith(filename, ".txt")}">fn:escapeXml把一些字符转成XML表示,例如<字符应该转为<${fn:escapeXml(param:info)}fn:indexOf子字符串在母字符串中出现的位置${fn:indexOf(name, "-")}fn:join将数组中的数据联合成一个新字符串,并使用指定字符格开${fn:join(array, ";")}fn:length获取字符串的长度,或者数组的大小${fn:length(shoppingCart.products)}fn:replace替换字符串中指定的字符${fn:replace(text, "-", "•")}fn:split把字符串按照指定字符切分${fn:split(customerNames, ";")}fn:startsWith判断字符串是否以某个子串开始<c:if test="${fn:startsWith(product.id, "100-")}">fn:substring获取子串${fn:substring(zip, 6, -1)}fn:substringAfter
获取从某个字符所在位置开始的子串
${fn:substringAfter(zip, "-")}fn:substringBefore获取从开始到某个字符所在位置的子串${fn:substringBefore(zip, "-")}fn:toLowerCase转为小写${fn.toLowerCase(product.name)}fn:toUpperCase转为大写字符${fn.UpperCase(product.name)}fn:trim去除字符串前后的空格${fn.trim(name)}
<!-- 函数说明 -->
函数
描述
fn:contains(string, substring)
如果参数string中包含参数substring,返回true
fn:containsIgnoreCase(string, substring)
如果参数string中包含参数substring(忽略大小写),返回true
fn:endsWith(string, suffix)
如果参数 string 以参数suffix结尾,返回true
fn:escapeXml(string)
将有特殊意义的XML (和HTML)转换为对应的XML character entity code,并返回
fn:indexOf(string, substring)
返回参数substring在参数string中第一次出现的位置
fn:join(array, separator)
将一个给定的数组array用给定的间隔符separator串在一起,组成一个新的字符串并返回。
fn:length(item)
返回参数item中包含元素的数量。参数Item类型是数组、collection或者String。如果是String类型,返回值是String中的字符数。
fn:replace(string, before, after)
返回一个String对象。用参数after字符串替换参数string中所有出现参数before字符串的地方,并返回替换后的结果
fn:split(string, separator)
返回一个数组,以参数separator 为分割符分割参数string,分割后的每一部分就是数组的一个元素
fn:startsWith(string, prefix)
如果参数string以参数prefix开头,返回true
fn:substring(string, begin, end)
返回参数string部分字符串, 从参数begin开始到参数end位置,包括end位置的字符
fn:substringAfter(string, substring)
返回参数substring在参数string中后面的那一部分字符串
fn:substringBefore(string, substring)
返回参数substring在参数string中前面的那一部分字符串
fn:toLowerCase(string)
将参数string所有的字符变为小写,并将其返回
fn:toUpperCase(string)
将参数string所有的字符变为大写,并将其返回
fn:trim(string)
去除参数string 首尾的空格,并将其返回
相关推荐
- URI:`http://java.sun.com/jsp/jstl/functions` - 主要标签:`<fn:length>`、`<fn:substring>`等。 #### 四、核心标签库详解 ##### 1. `<c:out>` - **功能**:主要用于输出数据。 - **属性**: - `value`:...
- **URI**:`http://java.sun.com/jsp/jstl/functions` - **常用标签**: - `split`:字符串分割。 - `length`:获取字符串长度。 - `indexOf`:查找字符串索引。 #### 核心标签库详解 1. **`<c:out>`标签** ...
| Functions | `http://java.sun.com/jsp/jstl/functions` | fn | #### JSTL 核心标签库详解 **核心标签库**是最常用的标签库之一,它提供了多种标签来帮助开发者更高效地处理 JSP 页面中的逻辑。这些标签主要...
- **URI**: `http://java.sun.com/jsp/jstl/functions` - **前缀**: `fn` #### 三、核心标签库 核心标签库是JSTL中最常用的标签库之一,提供了多种实用的功能,下面详细介绍其中的几个常用标签: 1. **<c:out>*...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %> <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <!-- 如果使用XML处理 --> <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %> ``` **3. JSTL常用标签示例:** - **`<c:...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> <!-- 根据需要引入其他标签库 --> ``` 这样,就可以在JSP页面中使用JSTL提供的标签了。例如,用`<c:forEach>`进行循环,`<c:if>`进行条件...
- **URI**:`http://java.sun.com/jsp/jstl/functions` #### 五、EL(Expression Language)与JSTL的结合 - **EL简介**:EL是一种简洁的数据访问语言,专门用于获取数据模型对象中的属性值,无需编写任何Java代码。...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ``` 这里,`prefix`是标签前缀,`uri`是对应的命名空间。 **3. JSTL核心标签** - `<c:set>`:设置变量。 - `<c:out>`:安全地输出变量...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %> <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ``` 3. **使用JSTL标签**: 使用`<c:forEach>`, `<c:if>`, `<fmt:formatDate>`等标签进行编程。 **示例:** ```jsp <c:forEach items="$...
<%@ taglib uri="http://java.sun.com/jstl/functions" prefix="fn" %> <c:forEach items="${fn:split('a,b,c', ',')}" var="item"> <c:out value="${item}" /> </c:forEach> ``` ### 小结 本文详细介绍了...
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> ``` **JSTL核心标签库(C标签):** JSTL的核心标签库提供了丰富的功能,包括表达式控制、流程控制、循环和URL操作。 **1. 表达式控制...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ``` #### 核心标签 (Core Tags) JSTL的核心标签提供了以下几种类型的标签: 1. **变量支持**: - `<c:set>`:设置变量值。 - `<c:...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ``` 接下来,我们将详细介绍`jstl_fn`标签库中的几个常用函数及其用途。 #### 三、常用函数介绍 1. **`fn:contains`** - **功能**:...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ``` - 如果使用JDBC标签,还需要导入相应的数据库驱动。 ### 示例应用 下面是一个简单的JSTL示例,展示了如何使用`<c:forEach>`标签...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> ``` 通过这些库,你可以进行日期格式化、字符串操作、国际化等功能。 总之,JSTL Taglib的配置和使用极大地简化了JSP的编程,提高了...
**JSTL(JavaServer Pages Standard Tag Library)**是Java服务器端的一个重要标签库,它提供了一系列的标签来简化JSP页面的开发,使得开发者能够更高效地编写动态网页。JSTL主要分为五个核心部分:Core、XML、JDBC、...