閱讀252 返回首頁    go 技術社區[雲棲]


解決web-app_2_4.xsd驗證web.xml時報j2ee_web_services_client_1_1.xsd找不到的問題

解決web-app_2_4.xsd驗證web.xml時報j2ee_web_services_client_1_1.xsd找不到的問題
web.xml
代碼
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="https://java.sun.com/xml/ns/j2ee"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://java.sun.com/xml/ns/j2ee
https://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
要在網上讀取驗證文件 https://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd 來驗證web.xml文件格式的正確性,導致速度變慢。
該驗證在修改xml文件後,每次保存文件時都要進行執行的。
 
一、XMLSpy中的解決辦法
1、下載以下所有的驗證文件到本地,比如放:<XMLSpy_HOME>/Schemas/java目錄下
https://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
https://java.sun.com/xml/ns/j2ee/jsp_2_0.xsd
https://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd
https://java.sun.com/xml/ns/j2ee/j2ee_web_services_client_1_1.xsd
注意: j2ee_1_4.xsd 中卻包含了 Web services schema ,即如下:
代碼
<xsd:include schemaLocation="https://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd"/> 
但是要下載卻下載不了,於是上Sun Java去。。。
https://java.sun.com/xml/ns/j2ee/ 中有,顯示的仍是ibm的,但鏈接是sun的,可以直接下載下來的
於是索性在 j2ee_1_4.xsd 就更改掉它:)
代碼
            <!-- <xsd:include schemaLocation="https://www.ibm.com/webservices/xsd/j2ee_web_services_client_1_1.xsd"/> -->
            <xsd:include schemaLocation="j2ee_web_services_client_1_1.xsd"/>
2、在 <XMLSpy_HOME>/MainCatalog.xml 文件中增加如下內容並保存
代碼
            <!-- web-app 2.4 Section -->
            <uri name="https://java.sun.com/xml/ns/j2ee" uri="schemas/java/web-app_2_4.xsd"/>
3、重啟XMLSpy,打開web.xml,然後按F8吧,綠色的打色出現了吧。
二、Eclipse中的解決辦法
1、同上下載所有的驗證文件到本地。。。
2、Windows ==> Preferences ==> Web and XML ==> XML Catalog,然後右邊窗口點擊 add 按鈕,打開 Add XML Catalog Entry 窗口。URI選擇框選擇到 web-app_2.4.xsd 文件 ,確定後,Key Type 會自動選中 Namespace Name ,Key會自動填入: https://java.sun.com/xml/ns/j2ee ,OK 確定即可。
3、重新打開web.xml
 

最後更新:2017-04-02 00:06:21

  上一篇:go 關於WebLogic 9.2與10.0中console異地IP登錄不上的解決方法
  下一篇:go 做技術要把自己變的單純,做管理要把自己變圓滑