<?xml version="1.0" encoding="UTF-8"?><web-app id="WebApp_ID" version="2.4" 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/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name> TagStudy2 </display-name> <jsp-config> <taglib> <taglib-uri>/hello</taglib-uri> <taglib-location>/WEB-INF/HelloTag.tld</taglib-location> </taglib> </jsp-config>
<welcome-file-list> <welcome-file>default.jsp</welcome-file> </welcome-file-list>
</web-app>从servlet2.4开始,taglib的uri是在标签库描述符中(tld)指定的,就像下面:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"><taglib> <tlibversion>1.0</tlibversion> <jspversion>1.1</jspversion> <shortname>bean</shortname> <uri>http://jakarta.apache.org/struts/tags-bean</uri>
任何需要使用这个标签库的页面都可以通过下面的页面级指令来引用它。标签库不需要再在web.xml文件中引用:<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
下面一个表是struts标签的uri:
Tag library
Struts 1.1 URI
Struts 1.2 URI
struts-bean
http://jakarta.apache.org/struts/tags-bean
http://struts.apache.org/tags-bean
struts-html
http://jakarta.apache.org/struts/tags-html
http://struts.apache.org/tags-html
struts-logic
http://jakarta.apache.org/struts/tags-logic
http://struts.apache.org/tags-logic
struts-nested
http://jakarta.apache.org/struts/tags-nested
http://struts.apache.org/tags-nested
struts-template
http://jakarta.apache.org/struts/tags-template
不再包括,被Tiles代替
struts-tiles
http://jakarta.apache.org/struts/tags-tiles
http://struts.apache.org/tags-tiles
struts-bean-el
http://jakarta.apache.org/struts/tags-bean-el
http://struts.apache.org/tags-bean-el
struts-html-el
http://jakarta.apache.org/struts/tags-html-el
http://struts.apache.org/tags-html-el
struts-logic-el
http://jakarta.apache.org/struts/tags-logic-el
http://struts.apache.org/tags-logic-el
sturts标签的可以直接通过uri引用,也可以通过在web.xml中声明再使用。直接通过uri引用,则不再需要tld文件,如果是web.xml的话,灵活性比较大,uri以后改变的话,只需要在web.xml中改变,不用在其他页面中改变。
Powered by: IT博客 Copyright © D主