简体   繁体   English

JSP taglib中uri和tagdir有什么区别

[英]what is the difference between uri and tagdir in JSP taglib

I am cofused between tagdir and uri used in taglib directive. 我在taglib指令中使用的tagdiruri之间tagdir What is the real difference between using tagdir and uri ? 使用tagdiruri之间的真正区别是什么?

Examples : 例子 :

<%@ 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" %>

to the best of my understanding: 据我所知:

1) I can access non-custom tags from the uri referencing them by the provided prefix (eg: 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> ). 1)我可以从uri通过提供的prefix引用它们的方式访问非自定义标签(例如:如果uri定义了标签hello ,则在粘贴taglib-uri的页面中,我可以将其作为<notMyTags:hello><otherTags: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 (eg: 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> ) 2)我可以访问在tagdir指定的路径中定义的自定义标签,这些路径由它们的.tag文件名引用,因为每个自定义标签都对应于一个.tag文件(例如:如果hello.tagtagDir指定路径中的文件,则在页面中将taglib粘贴到的地方,我可以作为<myTags:hello>来访问它)

The two directive are used for two different concepts of custom JSP tags. 这两个伪指令用于定制JSP标记的两个不同概念。

1) You use uri to reference a tag library , which is usually delivered in a jar and/or defined in a .tld file. 1)您使用uri来引用标签 ,该标签通常在jar中提供和/或在.tld文件中定义。 These can be written in Java (implementing one of the `javax.servlet.jsp.tagext.JspTag' subinterfaces) or as plain JSP tagfiles. 这些可以用Java编写(实现“ javax.servlet.jsp.tagext.JspTag”子接口之一)或作为纯JSP标记文件。

2) You use tagdir to reference JSP tagfiles within /WEB-INF/tags (or subdirectories thereof). 2)您可以使用tagdir来引用/WEB-INF/tags (或其子目录)中的JSP /WEB-INF/tags Those can not be Java classes. 那些不能是Java类。

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标记文件的更多信息,请参见Orcale网站上的J2EE教程: http ://docs.oracle.com/javaee/1.4/tutorial/doc/JSPTags5.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM