Custom EL function, el Function
Custom EL Functions
Procedure
1. Compile a java class and use static methods in the class to implement the specific functions of the custom EL function.
2. Compile the tag library description file and declare the function. Suffix tld, saved in WEB-INF
3. reference the tag library on the jsp page and call the EL function to implement the corresponding functions.
The java method must be a static method or the package Day14 error is reported; /*** process the carriage return and space characters in the String * @ author zql_pc **/public class StringDeal {// public static method public static String shiftEnter (String str) {String newStr = str. replaceAll ("\ r \ n", "<br/>"); // Replace the carriage return newStr = newStr. replace ("", "& nbsp"); // replace the carriage return newStr ;}} configuration <? 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 web-jsptaglibrary_2_0.xsd" version = "2.0"> <tlib-version> 1.0 </tlib-version> <uri>/stringDeal </uri> <function> <name> shiftEnter </name> <function-class> Day14.StringDeal </function-class> <function-signature> java. lang. string shiftEnter (java. lang. string) </function-signature> </function> </taglib> jsp page