自訂函數標籤(JSTL)

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   ar   使用   java   sp   

建立自訂函數標籤步驟:

  1、建立類,並且方法只能是靜態

    public static void operation(calculator cal)

  2、書寫tld

    

 1 <taglib xmlns="http://java.sun.com/xml/ns/j2ee" 2   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" 4   version="2.0"> 5   <tlib-version>1.0</tlib-version>//版本 6   <short-name>myfn</short-name>//名稱 7   <uri>http://www.cnblogs.com/liuwt365/myfuntags</uri>//引用——全球唯一 8   <function> 9       <name>calcul</name>//名稱10       <function-class>cn.test.calculator</function-class>//函數類11       <function-signature>void operation(cn.test.calculator)</function-signature>//函數說明12   </function>13   14   15 </taglib>

 

  3、在JSP頁面引用

  

1 <%@taglib uri="http://www.cnblogs.com/liuwt365/myfuntags" prefix="myfn"  %>

 

 

使用:

${myfn:calcul(cal)}

 

自訂函數標籤(JSTL)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.