分享

jstl的tld配置

 qin5 2011-07-22

jstl的tld配置

分类: Java相关 640人阅读 评论(0) 收藏 举报

一.JSTL库

standard.jar

jstl.jar

 

二.tld配置

1.非自动加载方式

(1)拷贝tld文件

将tld文件拷到WEB-INF的tld文件夹下

 

(2)web.xml

<jsp-config>
  <taglib>
   <taglib-uri>http://java./jstl/core</taglib-uri>
   <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
  </taglib>
  <taglib>
   <taglib-uri>http://java./jstl/fmt</taglib-uri>
   <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
  </taglib>
  <taglib>
   <taglib-uri>http://java./jstl/fn</taglib-uri>
   <taglib-location>/WEB-INF/tld/fn.tld</taglib-location>
  </taglib>
 </jsp-config>

 

(3)jsp中引用taglib

<%@ taglib prefix="c" uri="http://java./jstl/core" %>

 

2.自动加载方式

Servlet2.4规范提供了对tld文件的自动加载,tld文件在standard.jar的META-INF文件夹中。

如:c.tld文件提供了对核心jstl标签的描述

<taglib xmlns="http://java./xml/ns/j2ee"
    xmlns:xsi="http://www./2001/XMLSchema-instance"
    xsi:schemaLocation="http://java./xml/ns/j2ee http://java./xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
    version="2.0">
   
  <description>JSTL 1.1 core library</description>
  <display-name>JSTL core</display-name>
  <tlib-version>1.1</tlib-version>
  <short-name>c</short-name>
  <uri>http://java./jsp/jstl/core</uri>

可以看到其引用的uri为http://java./jsp/jstl/core

则在jsp中引用taglib为: <%@ taglib prefix="c" uri="http://java./jsp/jstl/core" %>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多