El function Library

Source: Internet
Author: User
Tags tld

Overview * * * *:

El function library is a third party to the El extension, the following study of the El function library is added by Jstl, Jstl next

The El function library defines some static methods that have return values . They are then called through the El language! Of course, not only jstl can define the El function library, we can also customize the El function library.

The El Library contains many ways to manipulate strings, as well as operations on collection objects. For example: ${fn:length ("abc")} will output 3, that is, the length of the string

Import Function Library * * * *:

Because it is a third party thing, so need to import, import need to use taglib instruction!

<%@ taglib prefix= "FN" uri= "Http://java.sun.com/jsp/jstl/functions"%>

Common methods of Function library * * * *:

?    String toUpperCase (String input):?    String toLowerCase (String input):? intindexOf (string input, String substring):?    Boolean contains (string input, String substring):?    Boolean containsignorecase (string input, String substring):?    Boolean StartsWith (string input, String substring):?    Boolean EndsWith (string input, String substring):? String substring (string input,intBeginindex,intendIndex):? String Substringafter (string input, string substring): Hello-world, "-"? Substringbefore (string input, string substring): Hello-world, "-"? String EscapeXML (String input): the string "> "," <".....     Escaped!?    String trim (String input):?    String replace (string input, String substringbefore, String substringafter):?    String[] Split (string input, string delimiters):? intLength (Object obj): Can get strings, arrays, the lengths of various collections!? String join (String array[], string separator):

The act, followed by a comment as the execution result

${fn:length (arr)}<br/><!--3-${fn:length (list)}<br/><!--1-${fn:tolowercase ("Hello")}<br/> <!--Hello--${fn:touppercase ("Hello")}<br/> <!--HELLO--${fn:contains ("ABC","a")}<br/><!--true-${fn:containsignorecase ("ABC","Ab")}<br/><!--true-${fn:contains (arr,"a")}<br/><!--true-${fn:containsignorecase (list,"A")}<br/><!--true-${fn:endswith ("Hello.java",". Java")}<br/><!--true-${fn:startswith ("Hello.java","Hell")}<br/><!--true-${fn:indexof ("Hello-world","-")}<br/><!--5-${fn:join (arr,";")}<br/><!--A;b;c-${fn:replace ("Hello-world","-","+")}<br/><!--Hello+world-${fn:join (Fn:split ("a;b;c;",";"),"-")}<br/><!--A-b-c-${fn:substring ("0123456789",6,9)}<br/><!--678-${fn:substring ("0123456789",5, -1)}<br/><!--56789-${fn:substringafter ("Hello-world","-")}<br/><!--World--${fn:substringbefore ("Hello-world","-")}<br/><!--Hello--${fn:trim ("a b c")}<br/><!--a b C--${fn:escapexml ("")}<br/> <!--

Custom Function Library * * * *:

4 custom EL function library

1), write a class, write a static method with a return value;

2), write the . tld file, you can refer to the Fn.tld file in Jstl to write, put the . tld file in the /web-inf directory;

3), add the taglib directive to the page and import the custom tag library

El function Library

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.