此規則會標示 JSP
myPage.jspf 中的 taglib
指引,這些指引會將相同的
字首
屬性值與不同的
uri
屬性值相關聯。 如果重新定義發生在
相同的 JSP 檔內,或者發生在靜態併入的
JSP 檔或片段內,則會標示重新定義。
根據 JSP 2.1 規格,字首不應該 在 JSP 的現行範圍內重新定義。 如果標籤庫 字首已使用 JSP 內或已併入 JSP 或片段中的不同 URI 來定義,則 產品必定會建立轉換 錯誤。 JSP 2.1 是 WebSphere Application Server 第 7 版中的新功能。 驗證是該版次的新功能,且未在之前版本中 施行。
最佳作法解決方案是變更
myPage.jspf 中的 taglib
指引以使用唯一字首,並更新受影響的 JSP 檔
以使用新字首。
如果您不想要變更 JSP 檔,則可以將
將 Web 模組的此行為回復為舊版的行為,方法是
在 IBM Web 延伸檔 (
ibm-web-ext.xml)
中設定下列屬性: ):
<jsp-attribute name="allowTaglibPrefixRedefinition"
value="true"/>
或者,您可以設定 Web 儲存器自訂內容
com.ibm.wsspi.jsp.allowtaglibprefixredefinition=true
,以影響伺服器上的所有應用程式,而非僅影響
第一個選項提供的特定 Web 模組。
在範例 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.
<%@ 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 檔來不同地重新定義 標籤庫 URI。 因此,會列出每個錯誤。
若要開啟 Eclipse 錯誤日誌,請按一下
視窗 > 顯示視圖 > 其他 > 錯誤日誌
.
如需相關資訊,請參閱: