在eclipse中运行JSF 2应用程序时我得到了几个信息日志,TLD被跳过,因为它已经定义如下:
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Jan 3, 2012 7:24:45 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
我很想知道,这个日志是什么意思?
这意味着在你的web应用的运行时类路径中有重复的TLD文件。由于tld通常包含在库JAR文件中,这反过来意味着在web应用程序的运行时类路径中有重复的JAR文件。
假设您没有触及appserver的/lib
文件夹或JDK的/lib
文件夹,那么这些副本在WAR构建的/WEB-INF/lib
文件夹中。清理它。
规范要求的uri优先顺序为:
J2EE platform taglibs - Tomcat doesn't provide these
web.xml entries
JARS in WEB-INF/lib & TLDs under WEB-INF (equal priority)
Additional entries from the container
Tomcat加载tld两次。
1,当Tomcat启动时,它加载tld以在tld文件中查找侦听器。
2,当编译第一个JSP文件时,它构建TLD对的缓存。
1、加载tld在tld文件中查找监听器
当从web.xml加载时,它会将来自web.xml的taglib-uri和来自tld文件的uri放到一个集合中。当从WEB-INF jar加载时,uri来自tld文件。
Tomcat需要避免重复的tld侦听器添加,所以它检查uri是否存在于集合中。如果uri已经存在,它记录您发布的消息,并跳过添加tld侦听器。
2、创建cache1) web.xml条目,标记uri是从web.xml
获得的2)扫描WEB-INF下的tld文件,标签uri从tld文件中获得
3)扫描jar,标签uri是从TLD文件中获得的。
如果uri已经存在,条目将被忽略
这意味着,例如,如果您使用Tomcat和Maven(或其他服务器),那么您发布的JSTL库已经在服务器上找到,并且服务器会报错。
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
在部署应用程序(在Tomcat上)时,您会得到错误消息:
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Mar 02, 2017 2:19:32 PM org.apache.catalina.startup.TaglibUriRule body
解决方案是使用'scope'标签和'提供'值,因为JSTL已经随Tomcat一起发货了(它只适用于您的IDE):
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>