Customize jstl function labels
Write a public class UtilFunction {public UtilFunction () {}/ *** @ param start 0, start intercept * @ param end, intercept * @ param info * @ param t fill * @ return */public static String subString (int start, int end, String info, String t) {String infostart = info. substring (0, start); String infoend = info. substring (end); return infostart + t + infoend;} // test public static void main (String [] args) {// 4 System after 3 mobile phone numbers. out. pri Ntln (UtilFunction. subString (3, 7, "15216888619", "*****") ;}2. Define a. tld file under web-inf <? 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"> <tlib-version> 1.0 </tlib-version> <short-name> my </short-name> <uri> http://www.xx.com </uri> <! -- JSTL custom function to obtain Province --> <function> <name> subString </name> <function-class> util. utilFunction </function-class> <function-signature> java. util. string subString (int, int, java. lang. string, java. lang. string) </function-signature> </function> </taglib> 3. web. xml definition <jsp-config> <taglib-uri> http://www.xx.com </taglib-uri> <taglib-location>/WEB-INF/tld/utilFunction. tld </taglib-location> </taglib> </jsp-config> 4. jsp page reference <% @ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn" %> <% @ taglib prefix = "yh" uri = "http://www.xx.com" % >$ {xx: subString (3, 7, userinfo. sMobile, "***")} Note: userinfo is request. setBean () request bound to $ {userinfo. sMobile} remove $ {} If fn function is used, directly use userinfo. sMobile