隨筆 - 117  文章 - 72  trackbacks - 0

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

          常用鏈接

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

          訂閱

          訂閱

          留言簿(7)

          隨筆分類(130)

          隨筆檔案(123)

          搜索

          •  

          積分與排名

          • 積分 - 155778
          • 排名 - 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 天堂露珠 閱讀(1364) 評論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 沙洋县| 玛沁县| 连城县| 上杭县| 都匀市| 岳池县| 海淀区| 河津市| 屯留县| 冀州市| 镇雄县| 临桂县| 于都县| 天气| 贵德县| 金乡县| 如东县| 水城县| 青冈县| 巴青县| 宝清县| 合川市| 塔城市| 义乌市| 荥阳市| 且末县| 延吉市| 德兴市| 丘北县| 赫章县| 井研县| 榆中县| 大化| 绍兴市| 镇江市| 林口县| 南京市| 临汾市| 卓尼县| 临澧县| 卫辉市|