我有一个 Web 应用程序正在从 Tomcat 5.5.35 迁移到 Tomcat 7.0.39。目前,有几个自定义标记库,每个都在自己的tld
文件中定义。这是一个例子:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>customTag</short-name>
<uri>http://www.something.com/util/customTag-db-taglib</uri>
<description>
Database tag library for Util
</description>
<tag>
<name>useBean</name>
<tag-class>com.mx.releasemgr.tags.db.UseBeanTag</tag-class>
<tei-class>com.mx.releasemgr.tags.db.UseBeanTEI</tei-class>
<body-content>EMPTY</body-content>
<attribute>
<name>id</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>oid</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>oidParameter</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>type</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
...
</taglib>
该文件夹中恰好有一份此 tld 文件的副本WEB-INF
。它从未被放入jar
文件中。
web.xml
看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
...
<jsp-config>
<taglib>
<taglib-uri>customTag</taglib-uri>
<taglib-location>/WEB-INF/customTag.tld</taglib-location>
</taglib>
</jsp-config>
...
此错误显示在catalina.out
Apr 11, 2013 3:50:08 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.mx.com/releasemgr/releasemgr-db-taglib is already defined
taglib 是这样导入的:
<%@ taglib uri="customTag" prefix="db" %>
我看过这个问题,但它似乎并不适用。我已经添加了<jsp-config>
,它没有帮助。我把标签库叫错了吗?URI 参数是否正确?任何帮助表示赞赏。