隨筆 - 117  文章 - 72  trackbacks - 0

          聲明:原創作品(標有[原]字樣)轉載時請注明出處,謝謝。

          常用鏈接

          常用設置
          常用軟件
          常用命令
           

          訂閱

          訂閱

          留言簿(7)

          隨筆分類(130)

          隨筆檔案(123)

          搜索

          •  

          積分與排名

          • 積分 - 156579
          • 排名 - 390

          最新評論

          [標題]:EL函數的使用
          [時間]:2009-4-3
          [摘要]:簡單的EL函數示例。
          [關鍵字]:EL,function,tld,jsp,jstl,標簽
          [平臺]:Tomcat6
          [作者]:Winty (wintys@gmail.com)

          [正文]:
          Step1:
              編寫所需要的類,將編譯生成的el.ELFunction復制到WEB-INF/中。
          package el;

          public class ELFunction{
              public static String toUpper(String str){
                  return str.toUpperCase();
              }
          }
          注意,用于EL中的函數需定義為static,不然會出錯。

          Step2:
                  在WEB-INF/tlds中添加el.tld,內容如下 :
          <?xml version = '1.0' encoding = 'GBK'?>
          <taglib 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" xmlns="http://java.sun.com/xml/ns/j2ee">
            <tlib-version>1.0</tlib-version>
            <short-name>fc</short-name>
            <uri>http://wintys/el</uri>
            <function>
               <name>toUpper</name>
               <function-class>el.ELFunction</function-class>
               <function-signature>
                  java.lang.String toUpper(java.lang.String)
               </function-signature>
            </function>
          </taglib>
          Step3:
              在WEB-INF/web.xml中添加:
          <taglib>
              <taglib-uri>http://wintys/el</taglib-uri>
              <taglib-location>/WEB-INF/tlds/el.tld</taglib-location>
          </taglib>
          Step4:
              編寫測試頁面ELFunction.jsp:
          <%@page contentType="text/html;charset=GBK" %>
          <%@taglib uri="http://wintys/el" prefix="myfun" %>
          EL Function:<br />
          ${myfun:toUpper("abcde")}
          重啟Tomcat后運行ELFunction.jsp即可得到結果。


          posted on 2009-04-03 21:29 天堂露珠 閱讀(1368) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 湘潭县| 托里县| 徐州市| 黔南| 清涧县| 石景山区| 岳普湖县| 临邑县| 那曲县| 宁化县| 安多县| 吴忠市| 鸡西市| 德钦县| 子洲县| 寿阳县| 义乌市| 栖霞市| 恩施市| 和平县| 监利县| 安吉县| 汪清县| 吉木乃县| 贵南县| 财经| 浪卡子县| 三台县| 靖西县| 遂宁市| 当涂县| 德惠市| 洛浦县| 沾化县| 东乡族自治县| 正宁县| 新干县| 宜昌市| 庆阳市| 连南| 东台市|