自定义标签fn

来源:互联网 发布:图形工作站 知乎 编辑:程序博客网 时间:2024/06/08 11:20

使用自定义标签fn:

需要jstl.jar包,然后在jsp页头导入

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>



自定义标签需要在web project下的webroot下的web-inf下新建一个文件


文件放.tld文件,这就是自定义fn标签的创建。

<?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>myfn</short-name>
    <uri>http://www.yinheedu.com</uri>

    <function>
        <description>
             select all categories
           </description>
        <name>findAllCategories</name>
        <function-class>com.yinhe.dao.CategoryDao</function-class>
        <function-signature>java.util.List findAllCategories()</function-signature>
    </function>

</taglib>

自定义的标签需要在jsp页面添加

<%@taglib prefix="myfn"  uri="http://www.yinheedu.com"%>那个地方需要用到fn标签


引用就行了。