请勿使用其他 URI 来重定义 taglib 前缀

此规则标记 JSP taglib 伪指令,该伪指令将同一 prefix 属性值与不同的 uri 属性值相关联。 如果在同一 JSP 文件内或者在静态包含的 JSP 文件或片段中进行了重新定义,那么将标记该重新定义。

根据 JSP 2.1 规范,不应在该 JSP 的当前作用域内重新定义前缀。 如果在 JSP 内或者在所包含 JSP 或片段内,已使用另一 URI 定义标记库前缀,那么该产品必然会产生转换错误。 JSP 2.1 是 WebSphere Application Server V7 中的新内容。 验证是该发行版的新功能,在先前版本中不会强制执行。

最佳实践解决方案是将 taglib 伪指令更改为使用唯一前缀,以及将受影响的 JSP 文件更新为使用新前缀。

如果您不想更改 JSP 文件,那么可通过设置 IBM Web 扩展文件 (ibm-web-ext.xml) 中的以下 JSP 属性来将 Web 模块的此行为撤销来恢复为先前版本的行为:

<jsp-attribute name="allowTaglibPrefixRedefinition" value="true"/>

或者,可设置 Web 容器定制属性 com.ibm.wsspi.jsp.allowtaglibprefixredefinition=true,以影响服务器上的所有应用程序,而不是仅影响第一个选项提供的特定 Web 模块。

示例 1:假定下列各行在同一 JSP 文件(名称为 Page1.jsp)中:
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/otherLib.tld" prefix="fmt"%>

在示例 1 中,将标记第二个条目,因为它是 fmt 的重新定义。 对于此示例,工具会将以下警告消息记录在 Eclipse 错误日志中:

!MESSAGE CWMIG1125W: The WebContent/Page1.jsp file attempted to redefine the URI value for the fmt prefix from /WEB-INF/fmt.tld to /WEB-INF/otherLib.tld.
The Do not redefine a taglib prefix using a different URI rule encountered the problem while analyzing the /MyJspProject/WebContent/Page1.jsp file in the MyJspProject project.

示例 2:假定 JSP 文件(名称为 Page2.jsp)具有以下内容:
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@ include file="myPage.jspf"%>

其中 myPage.jspf 包含以下行:

<%@ taglib uri="/WEB-INF/otherLib.tld" prefix="fmt"%>

在示例 2 中,将标记 myPage.jspf 中的 taglib 行。 在此示例中,您将看到记录在 Eclipse 错误日志中的以下警告:

!MESSAGE CWMIG1124W: The WebContent/myPage.jspf file attempted to redefine the URI value for the fmt prefix from /WEB-INF/fmt.tld to /WEB-INF/otherLib.tld in the scope of the WebContent/Page2.jsp file.
The Do not redefine a taglib prefix using a different URI rule encountered the problem while analyzing the /MyJspProject/WebContent/Page2.jsp file in the MyJspProject project.

请使用错误日志信息来帮助解决有冲突的文件。所包含 JSP 文件可导致在不同作用域中存在具有多个基本 JSP 文件的重新定义。在此情况下,可能多次标记某个文件,而单个修正将清除多个问题。同一所包含文件可能会以不同方式重新定义标记库 URI,具体取决于哪个 JSP 文件包含该文件。 由于此原因,会列示每个错误。

要打开 Eclipse 错误日志,请单击窗口 > 显示视图 > 其他 > 错误日志

有关更多信息,请参阅: