1. Create a new class, define a static method inside the class
Package com.tsh.utils; Import Java.net.URLEncoder; Public class Elfunc { publicstatic string UrlEncode (String str) { return Urlencoder.encode (str);} }
2. Create a new TLD under the web-inf folder (except lib and classess directories) file
<?XML version= "1.0" encoding= "UTF-8"?><taglibversion= "2.0"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"> <tlib-version>1.0</tlib-version> <Short-name>Elfunc</Short-name> <URI>Http://www.tsh.com/ELFunc</URI> <function> <name>UrlEncode</name> <Function-class>Com.tsh.utils.ELFunc</Function-class> <function-signature>Java.lang.String UrlEncode (java.lang.String)</function-signature> </function></taglib>
3.jsp Head Import
<% @taglib uri= "Http://www.tsh.com/ELFunc" prefix= "Elfunc"%>
4.el Label Use
<%=urlencoder.encode ("Taoshan")%>${elfunc:urlencode ("Taoshan")}
%E9%99%B6%E5%A3%AB%E6%B6%B5%E9%99%B6%E5%A3%AB%E6%B6%B5
manually import jstl using the jstl Tag Library
1. Download the compression pack and put Jstl.jar and standard.jar in Tomcat 's Lib directory under
2. Place the TLD in the web-inf directory
3.jsp page Import <% @taglib uri= "http://java.sun.com/jsp/jstl/functions" prefix= "FN"%>
4. Use ${fn:touppercase ("SDSDSDSSDSDSDSSDDSDSD")}
[Java EE] El Expressions call Java methods