JSP taglib中uri和tagdir有什么区别 [英] what is the difference between uri and tagdir in JSP taglib

查看:768
本文介绍了JSP taglib中uri和tagdir有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对taglib指令中使用的tagdiruri之间感到困惑. tagdiruri的真正区别是什么?

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.tagtagDir指定的路径,在粘贴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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆