With JSP, does the taglib URI mean that my site is reliant on the URI resolving?

对着背影说爱祢 提交于 2019-12-21 16:58:17

问题


I'm trying to implement a sitemesh decorator in my site. The example on their site has a full URI linking to their site for the taglib part of the decorator file:

<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>

Does this mean that my site is reliant on being able to access that site? Because i want to deploy inside an intranet which can't access the outside world.

Thanks


回答1:


No, it does not. The URI declared in taglib will be resolved locally as long as it matches the URI declared in tag library descriptor (or in your web.xml, depending on what JSP version your container implements).

See Java EE tutorial for more details.




回答2:


No. The URI is a Universal Resource Identifier, it is NOT a locator (URL). This means that the URI is used to uniquely identify each taglib in an internal registry of taglibs, much like a key is used to set/get values from a HashMap or Hashtable in Java.

According to the web application spec from Sun, resolving the URIs to actual tag libraries that can be loaded/called by the application takes place in the following order:

  1. Check the web.xml file for matching taglib tags that have the given URI in them and then follow the taglib-location tag to actually load the TLD.
  2. If no match with #1 was found, recursively check the META-INF directory of all the JARs in the application for TLDs that contain the URI that was specified.



回答3:


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

where the uri attribute value resolves to a location the container understands and the prefix attribute informs a container what bits of markup are custom actions.



来源:https://stackoverflow.com/questions/1806201/with-jsp-does-the-taglib-uri-mean-that-my-site-is-reliant-on-the-uri-resolving

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!