2011-03-04 39 views
8

我有在網絡XML的web.xml驗證錯誤

多了一個錯誤-Cannot解析名稱「的JavaEE:網絡APPTYPE」到(N)「類型定義」的組成部分。

和web.xml文件

<?xml version="1.0" encoding="UTF-8"?><!--error here--> 
<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" 

回答

10

你忘了xmlns:web命名空間。這是完整的Servlet 3.0兼容聲明。

<?xml version="1.0" encoding="UTF-8"?> 
<web-app 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
    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" 
    id="Your_Webapp_ID" version="3.0"> 

    <!-- Config here --> 

</web-app> 
+0

是不是XML標準的xmlns-屬性使用URI而不是URL?具體來說:xmlns:web =「http://java.sun.com/xml/ns/javaee」。如果沒有理由出現在這裏,我會在4周左右編輯答案。 – Tires 2012-12-23 11:29:24