隨筆 - 117  文章 - 72  trackbacks - 0

          聲明:原創(chuàng)作品(標(biāo)有[原]字樣)轉(zhuǎn)載時(shí)請(qǐng)注明出處,謝謝。

          常用鏈接

          常用設(shè)置
          常用軟件
          常用命令
           

          訂閱

          訂閱

          留言簿(7)

          隨筆分類(130)

          隨筆檔案(123)

          搜索

          •  

          積分與排名

          • 積分 - 155505
          • 排名 - 390

          最新評(píng)論

          [標(biāo)題]:EL函數(shù)的使用
          [時(shí)間]:2009-4-3
          [摘要]:簡(jiǎn)單的EL函數(shù)示例。
          [關(guān)鍵字]:EL,function,tld,jsp,jstl,標(biāo)簽
          [平臺(tái)]:Tomcat6
          [作者]:Winty (wintys@gmail.com)

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

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

          Step2:
                  在WEB-INF/tlds中添加el.tld,內(nèi)容如下 :
          <?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:
              編寫測(cè)試頁(yè)面ELFunction.jsp:
          <%@page contentType="text/html;charset=GBK" %>
          <%@taglib uri="http://wintys/el" prefix="myfun" %>
          EL Function:<br />
          ${myfun:toUpper("abcde")}
          重啟Tomcat后運(yùn)行ELFunction.jsp即可得到結(jié)果。


          posted on 2009-04-03 21:29 天堂露珠 閱讀(1362) 評(píng)論(0)  編輯  收藏 所屬分類: Java
          主站蜘蛛池模板: 西平县| 庄浪县| 台中市| 体育| 汉源县| 永吉县| 秭归县| 泰安市| 大名县| 交城县| 台东县| 措美县| 平江县| 梧州市| 松潘县| 景德镇市| 临江市| 峨边| 芜湖县| 藁城市| 南雄市| 九台市| 博白县| 五原县| 古丈县| 苗栗县| 淄博市| 新和县| 朝阳县| 开封县| 通山县| 阳泉市| 铁岭市| 奉化市| 武鸣县| 高淳县| 虎林市| 金平| 呼图壁县| 高陵县| 井冈山市|