JSP taglib中uri和tagdir有什么区别 [英] what is the difference between uri and tagdir in JSP taglib
问题描述
我对taglib
指令中使用的tagdir
和uri
之间感到困惑.
tagdir
和uri
的真正区别是什么?
I am cofused between tagdir
and uri
used in taglib
directive.
What is the real difference between using tagdir
and uri
?
示例:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="notMyTags" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="otherTags" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="myTags" %>
据我所知:
1)我可以通过提供的prefix
引用uri
中的非自定义标签来访问它们(例如:如果uri
定义了标签hello
,则在粘贴taglib-uri
的页面中,我可以通过<notMyTags:hello>
或<otherTags:hello>
来访问它.)
1) I can access non-custom tags from the uri
referencing them by the provided prefix
(e.g.: if the uri
defines the tag hello
, in the page where taglib-uri
is pasted, I can access it as <notMyTags:hello>
or <otherTags:hello>
).
2)我可以访问在tagdir
指定的路径中定义的自定义标签,这些自定义标签通过它们的.tag
文件名引用它们,因为每个自定义标签都对应一个.tag
文件(例如:如果hello.tag
是tagDir
指定的路径,在粘贴taglib
的页面中,我可以将其作为<myTags:hello>
)
2) I can access custom tags defined within the path specified in tagdir
referencing them by their .tag
filenames because each custom tag corresponds to a .tag
file (e.g.: if hello.tag
is a file in the tagDir
specified path, in the page where taglib
is pasted, I can access it as <myTags:hello>
)
推荐答案
两个指令用于自定义JSP标记的两个不同概念.
The two directive are used for two different concepts of custom JSP tags.
1)您使用uri
引用标签 library ,该标签通常在jar中提供和/或在.tld
文件中定义.这些可以用Java编写(实现"javax.servlet.jsp.tagext.JspTag"子接口之一)或作为纯JSP标记文件.
1) You use uri
to reference a tag library, which is usually delivered in a jar and/or defined in a .tld
file. These can be written in Java (implementing one of the `javax.servlet.jsp.tagext.JspTag' subinterfaces) or as plain JSP tagfiles.
2)您使用tagdir
引用/WEB-INF/tags
(或其子目录)中的JSP标记文件.这些不能是Java类.
2) You use tagdir
to reference JSP tagfiles within /WEB-INF/tags
(or subdirectories thereof). Those can not be Java classes.
请参阅Orcale网站上的J2EE教程,以获取有关JSP标记文件的更多信息: http://docs.oracle.com/javaee/1.4/tutorial/doc /JSPTags5.html
See the J2EE tutorial at Orcale's website for more information regarding JSP tagfiles: http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPTags5.html
这篇关于JSP taglib中uri和tagdir有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!