当前位置: 代码迷 >> Web前端 >> el表达式自定义函数的设立
  详细解决方案

el表达式自定义函数的设立

热度:68   发布时间:2012-09-16 17:33:17.0
el表达式自定义函数的设置
1.
     编写函数处理类,处理方法应该是public static 的
2.
     编写tld文件,可用模版如下
    <?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">
  <description>JSTL 1.1 functions library</description>
  <display-name>JSTL functions</display-name>
  <tlib-version>1.1</tlib-version>
  <short-name>fnn</short-name>
  <uri>/fnn</uri>
  <function>
    <description>liukai 20110224</description>
    <name>getHours</name>
    <function-class>
              //包含函数的类
com.huawei.csp.customization.lttb.cct.dao.HandlingTime
</function-class>
    <function-signature>
              //函数
       java.lang.String getHours(java.lang.String, java.lang.String)
    </function-signature>
</function>
</taglib>
3.在web.xml文件当中使用这个tld库
<jsp-config>  
        <taglib>  
            <!-- 配置标签的引用地址 JSP页面中引用时使用-->  
            <taglib-uri>/eltag</taglib-uri>  
            <!-- 配置标签的TLD文件地址 -->  
            <taglib-location>/WEB-INF/tld/ElTag.tld</taglib-location>  
        </taglib>  
    </jsp-config> 
4.在jsp文件当中引入taglib
  相关解决方案