国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

創(chuàng)建自定義的EL function(Creating a custom EL function)

2019-11-15 00:24:35
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
創(chuàng)建自定義的EL function(Creating a custom EL function)

測(cè)試環(huán)境: tomcat7,jdk1.7

1.First make a class with a static method like so:

package your.package;public class Functions {       public static String hello(String name) {         return "Hiya, " + name + ".";       }}

2. Then make a file called mytaglib.tld in WEB-INF/tags/:

<?xml version="1.0" encoding="ISO-8859-1" ?>    <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/javaee/web-jsptaglibrary_2_1.xsd"       version="2.1">       <tlib-version>1.0</tlib-version>      <uri>http://www.your.url/tablib_name</uri>      <function>          <name>hello</name>          <function-class>your.package.Functions</function-class>          <function-signature>java.lang.String hello(java.lang.String)</function-signature>      </function>      </taglib>     

3.The uri would be used if we were accessing this directly, but instead we’ll be accessing the url from the web.xml below:

 <web-app         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-app_2_4.xsd"        version="2.4">        ...       <jsp-config>       <taglib>         <taglib-uri>           http://some.thing/mine         </taglib-uri>         <taglib-location>           /WEB-INF/tags/mytaglib.tld         </taglib-location>       </taglib>        </jsp-config>       ...     </web-app>

4. Note we’re pointing to the mytaglib.tld file just created. And taglib-uri is how we’ll refer to it in the JSP:

    <%@ taglib uri="http://some.thing/mine" 


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 朔州市| 盱眙县| 宿松县| 大荔县| 黄冈市| 松潘县| 苍梧县| 永新县| 新沂市| 栖霞市| 古交市| 武定县| 云安县| 库车县| 微山县| 天峻县| 南宁市| 琼海市| 香港 | 邓州市| 新和县| 大同县| 图们市| 那曲县| 塘沽区| 宝山区| 治县。| 蓬溪县| 平凉市| 武清区| 绥德县| 甘德县| 镇坪县| 南乐县| 安徽省| 彩票| 金坛市| 黄石市| 连山| 宁国市| 江津市|