2

当我们使用下面的编译器指令并且我不在 web.xml 中使用时

<%@ taglib uri="/struts-tags" prefix="s"%>

tomcat 会用它做什么?taglib 如何找到 .tld?它有搜索顺序吗?我想知道原理。谢谢~

4

2 回答 2

5

Here's the way it works:

The JAR file that contains your tag library has a .tld file, which in turn has a <uri> tag with a string that needs to match the value in your JSP.

For example, the standard JSTL JAR has a c.tld file with this URI:

<uri>http://java.sun.com/jsp/jstl/core</uri>

That's the URI that you need to use the core JSTL tag library.

It has nothing to do with where you put the JARs and everything to do with the .tld.

于 2012-04-09T15:01:06.753 回答
0

容器在你的Web应用程序中搜索所有.tld,首先在WEB-INF目录中,然后在WEB-INF的所有子目录中,如果有jar文件他在里面搜索,如果有tld文件。之后,容器映射每个使用 tld 文件找到的 uri。

于 2015-01-20T18:05:25.657 回答