JSTL function tag library fn tag, jstl function fn tag

Source: Internet
Author: User

JSTL function tag library fn tag, jstl function fn tag

Before using the jstl function tag library, you must introduce the following on the page:

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

 

1. fn: contains (string, substring)
Returns true if the string parameter contains the substring parameter.

 

2. fn: containsIgnoreCase (string, substring)
Returns true if the string parameter contains the substring (Case Insensitive ).

 

3. fn: endsWith (string, suffix)
Returns true if string ends with suffix.

 

4. fn: escapeXml (string)
Convert the XML (HTML) with special meaning to the corresponding XML character entity code and return it.

5. fn: indexOf (string, substring)
Returns the position where the substring parameter appears for the first time in the string parameter.

 

6. fn: join (array, separator)
Concatenates a given array with a given delimiter separator to form a new string and return it.

 

7. fn: length (item)
Returns the number of elements contained in the parameter item. The parameter Item type is array, collection, or String. For the String type, the return value is the number of characters in the String.

 1     <body>        2         <% 3             String a[] = {"aa","bb","cc","dd"}; 4             request.setAttribute("array",a); 5             request.setAttribute("store","guomei8899"); 6         %>  7         <c:if test="${fn:contains('guomeiddd','guoMei')}">ok</c:if><br> 8         <c:if test="${fn:containsIgnoreCase(store,'guoMei')}">ok ok</c:if><br> 9         <c:if test="${fn:endsWith(store,'99')}">end</c:if><br>10         <c:out value="${fn:escapeXml('<>')}"/><br>11         <c:out value="${fn:indexOf(store,'om')}"/><br>12         <c:out value="${fn:join(array,'|')}"/><br>13         <c:out value="${fn:length(array)}"/><br>14     </body> 

8. fn: replace (string, before, after)
Returns a String object. Replace all the places where the before parameter appears in the parameter string with the parameter after string, and return the replaced result.

 

9. fn: startsWith (string, prefix)
Returns true if the string parameter starts with the prefix.

 

10. fn: substring (string, begin, end)
Returns the string, starting from the begin parameter to the end parameter.

 

11. fn: substringAfter (string, substring)
Returns the part of the substring that follows the string parameter.

 

12. fn: substringBefore (string, substring)
Returns the part of the string before the substring parameter.

 

13. fn: toLowerCase (string)
Converts all characters of the string parameter to lowercase and returns the result.

 

14. fn: toUpperCase (string)
Converts all characters of the string parameter to uppercase and returns the result.

 

15. fn: trim (string)
Remove the spaces at the beginning and end of the string parameter and return it.

 1     <body>        2         <% 3             String a[] = {"aa","bb","cc","dd"}; 4             request.setAttribute("array",a); 5             request.setAttribute("store","guomei8899"); 6             request.setAttribute("user","u1,u2,u3,u4,u5"); 7             request.setAttribute("test","aBcDeF   "); 8         %>  9         <c:out value="${fn:replace(store,'8','9')}"/><br>10         <c:out value="${fn:split(user,',')}"/><br>11         <c:out value="${fn:startsWith(store,'g')}"/><br>12         <c:out value="${fn:substring(store,2,5)}"/><br>13         <c:out value="${fn:substringAfter(store,'mei')}"/><br>14         <c:out value="${fn:substringBefore(store,'mei')}"/><br>15         <c:out value="${fn:toLowerCase(test)}"/><br>16         <c:out value="${fn:toUpperCase(test)}"/><br>17         <c:out value="${test}hoho"/><br>18         <c:out value="${fn:trim(test)}hoho"/><br>19     </body>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.