FN function in El expression (reprinted)

Source: Internet
Author: User
Jstl uses expressions to simplify Page code. This is very convenient for some standard methods, such as the getter/setter method of bean, to access request parameters, context, and session data, however, in practical applications, we often need to call some methods of objects on the page. For example, when I need to call the length method of a string to obtain the length of a string, in the previous development process, we had to convert the object to the string class first, and then call its length method. Such code is cumbersome and error-prone.

Therefore, jstl has several built-in methods for string operations, which can be used directly in expressions, greatly simplifying the code and providing code readability. A function must be used in the expression of jstl. The format is as follows:

$ {Ns: methodname (ARGs ....)}

Before using these functions, you must introduce the standard function declaration in JSP.

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

The following is a list of methods self-contained in jstl and their descriptions.

Function Name Function Description Example
FN: Contains Determines whether a string contains another string. <C: If test = "$ {fn: Contains (name, searchstring)}">
FN: containsignorecase Determines whether the string contains another string (case-insensitive) <C: If test = "$ {fn: containsignorecase (name, searchstring)}">
FN: endswith Judge whether the string ends with another string <C: If test = "$ {fn: endswith (filename,". txt ")}">
FN: escapexml Convert some characters to XML Representation. For example, <character should be converted to <; $ {Fn: escapexml (Param: INFO )}
FN: indexof Position of the substring in the parent string $ {Fn: indexof (name ,"-")}
FN: Join Combines the data in the array into a new string and uses the specified character lattice $ {Fn: Join (array ,";")}
FN: Length Returns the length of a string or the size of an array. $ {Fn: length (shoppingcart. Products )}
FN: replace Replace the specified character in the string $ {Fn: Replace (text, "-", "& #149 ;")}
FN: Split Splits a string by a specified character. $ {Fn: Split (customernames ,";")}
FN: startswith Determines whether a string starts with a substring. <C: If test = "$ {fn: startswith (products. ID," 100-")}">
FN: substring Obtain substrings $ {Fn: substring (ZIP, 6,-1 )}
FN: substringafter

Obtains the substring starting from the position of a character.

$ {Fn: substringafter (ZIP ,"-")}
FN: substringbefore Obtains the substring from the start to the position of a character. $ {Fn: substringbefore (ZIP ,"-")}
FN: tolowercase Lowercase $ {Fn. tolowercase (product. Name )}
FN: touppercase Convert to uppercase characters $ {Fn. uppercase (product. Name )}
FN: trim Removes spaces before and after a string. $ {Fn. Trim (name )}

Function

Description

FN: Contains (string, substring)

Returns true if the string parameter contains the substring parameter.

FN: containsignorecase (string, substring)

Returns true if the string parameter contains the substring (Case Insensitive ).

FN: endswith (string, suffix)

Returns true if string ends with suffix.

FN: escapexml (string)

Convert the XML (HTML) with special meaning to the corresponding XML character entity code, and return

FN: indexof (string, substring)

Returns the position where the substring parameter appears for the first time in the string parameter.

FN: Join (array, separator)

Concatenates a given array with a given delimiter separator to form a new string and return it.

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.

FN: Replace (string, before, after)

Returns a String object. Replace all places where the before parameter appears in the parameter string with the parameter after string, and return the replaced result.

FN: Split (string, separator)

Returns an array that uses the separator parameter as the delimiter to split the string parameter. Each part of the split is an element of the array.

FN: startswith (string, prefix)

Returns true if the string parameter starts with the prefix.

FN: substring (string, begin, end)

Returns the string part of the parameter, starting from the begin parameter to the end position of the parameter, including the character of the end position.

FN: substringafter (string, substring)

Returns the part of the substring that follows the string parameter.

FN: substringbefore (string, substring)

Returns the part of the substring before the string parameter.

FN: tolowercase (string)

Convert all characters of the string parameter to lowercase and return

FN: touppercase (string)

Converts all characters of the string parameter to uppercase and returns

FN: trim (string)

Remove the spaces at the beginning and end of the string parameter and return it.




Http://blog.csdn.net/qingwangyoucao/article/details/6218069

Use and intercept strings of FN functions in El expressions

Article category: Java programmingKeywords: Use of FN function in El expression and string Truncation

I have worked on a project for a month. I have written several articles that I often use today to facilitate future reference.
FN function:
  1. Add the following code to the header of the JSP page before use:
  2. <% @ Taglib prefix = "FN" uri = "http://java.sun.com/jsp/jstl/functions" %>
  3. The following is a list of methods self-contained in jstl and their descriptions.
  4. Function Description Example
  5. FN: Contains determine whether a string contains another string <C:IfTest = "$ {fn: Contains (name, searchstring)}">
  6. FN: containsignorecase: determines whether the string contains another string (case-insensitive) <C:IfTest = "$ {fn: containsignorecase (name, searchstring)}">
  7. FN: endswith: Determine whether the string ends with another string <C:IfTest = "$ {fn: endswith (filename,". txt ")}">
  8. FN: escapexml converts some characters into XML Representation. For example, <character should be converted to <$ {fn: escapexml (Param: INFO )}
  9. Position where the FN: indexof substring appears in the parent string $ {fn: indexof (name ,"-")}
  10. FN: Join combines the data in the array into a new string and uses the specified character lattice to open $ {fn: Join (array ,";")}
  11. FN: length gets the length of the string, or the size of the array $ {fn: length (shoppingcart. Products )}
  12. FN: replace Replace the specified character in the string $ {fn: Replace (text, "-", "& #149 ;")}
  13. FN: Split the string according to the specified characters $ {fn: Split (customernames ,";")}
  14. FN: startswith: determines whether a string starts with a substring. <C:IfTest = "$ {fn: startswith (product. ID," 100-")}">
  15. FN: substring get substring $ {fn: substring (ZIP, 6,-1 )}
  16. FN: substringafter obtains the substring starting from the position of a character.
  17. $ {Fn: substringafter (ZIP ,"-")}
  18. FN: substringbefore: Obtain the substring from the start to the position of a character $ {fn: substringbefore (ZIP ,"-")}
  19. FN: Convert tolowercase to lower case $ {fn. tolowercase (product. Name )}
  20. FN: Convert touppercase to uppercase characters $ {fn. uppercase (product. Name )}
  21. FN: trim spaces before and after the trim string $ {fn. Trim (name )}
[Java]View plaincopy
  1. Add the following code to the header of the JSP page before use:
  2. <% @ Taglib prefix = "FN" uri = "http://java.sun.com/jsp/jstl/functions" %>
  3. The following is a list of methods self-contained in jstl and their descriptions.
  4. Function Description Example
  5. FN: Contains determine whether the string contains another string <C: If test = "$ {fn: Contains (name, searchstring)}">
  6. FN: containsignorecase determine whether the string contains another string (case-insensitive) <C: If test = "$ {fn: containsignorecase (name, searchstring)}">
  7. FN: endswith determine whether the string ends with another string <C: If test = "$ {fn: endswith (filename,". txt ")}">
  8. FN: escapexml converts some characters into XML Representation. For example, <character should be converted to <$ {fn: escapexml (Param: INFO )}
  9. Position where the FN: indexof substring appears in the parent string $ {fn: indexof (name ,"-")}
  10. FN: Join combines the data in the array into a new string and uses the specified character lattice to open $ {fn: Join (array ,";")}
  11. FN: length gets the length of the string, or the size of the array $ {fn: length (shoppingcart. Products )}
  12. FN: replace Replace the specified character in the string $ {fn: Replace (text, "-", "& #149 ;")}
  13. FN: Split the string according to the specified characters $ {fn: Split (customernames ,";")}
  14. FN: startswith determine whether a string starts with a substring <C: If test = "$ {fn: startswith (product. ID," 100-")}">
  15. FN: substring get substring $ {fn: substring (ZIP, 6,-1 )}
  16. FN: substringafter obtains the substring starting from the position of a character.
  17. $ {Fn: substringafter (ZIP ,"-")}
  18. FN: substringbefore: Obtain the substring from the start to the position of a character $ {fn: substringbefore (ZIP ,"-")}
  19. FN: Convert tolowercase to lower case $ {fn. tolowercase (product. Name )}
  20. FN: Convert touppercase to uppercase characters $ {fn. uppercase (product. Name )}
  21. FN: trim spaces before and after the trim string $ {fn. Trim (name )}



Function Description

FN: Contains (string, substring)
Returns true if the string parameter contains the substring parameter.

FN: containsignorecase (string, substring)
Returns true if the string parameter contains the substring (Case Insensitive ).

FN: endswith (string, suffix)
Returns true if string ends with suffix.

FN: escapexml (string)
Convert the XML (HTML) with special meaning to the corresponding XML character entity code, and return

FN: indexof (string, substring)
Returns the position where the substring parameter appears for the first time in the string parameter.

FN: Join (array, separator)
Concatenates a given array with a given delimiter separator to form a new string and return it.

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.

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

FN: Split (string, separator)
Returns an array that uses the separator parameter as the delimiter to split the string parameter. Each part of the split is an element of the array.

FN: startswith (string, prefix)
Returns true if the string parameter starts with the prefix.

FN: substring (string, begin, end)
Returns the string part of the parameter, starting from the begin parameter to the end position of the parameter, including the character of the end position.

FN: substringafter (string, substring)
Returns the part of the substring that follows the string parameter.

FN: substringbefore (string, substring)
Returns the part of the substring before the string parameter.

FN: tolowercase (string)
Convert all characters of the string parameter to lowercase and return

FN: touppercase (string)
Converts all characters of the string parameter to uppercase and returns

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

 

 

FN function in El expression (reprinted)

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.