2011-02-14 161 views
0

這些XML驗證結果實際上代表什麼?XML驗證缺失標記

「nbres:/org/netbeans/modules/j2ee/ddloaders/catalog/resources/datatypes.dtd」中的引用實體。 cvc-complex-type.2.4.a:找到以元素「filter-name」開頭的無效內容。 「{」http://java.sun.com/xml/ns/javaee":description,「http://java.sun.com/xml/ns/javaee":display-name」,http:/ /java.sun.com/xml/ns/javaee":icon,「http://java.sun.com/xml/ns/javaee":servlet-name}」。 [48] 元素類型「servlet」必須由匹配的結束標記「」終止。 [50] XML驗證已完成。

我不太熟悉這些!

我的文件:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.5" 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_2_5.xsd"> 

    <display-name>KeyCard</display-name> 
- <context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>/WEB-INF/applicationContext.xml 
    /WEB-INF/tilesViewContext.xml 
    /WEB-INF/ldap-config.xml 
    /WEB-INF/security-config.xml 
    /WEB-INF/idm-config.xml 
    </param-value> 
    </context-param> 

<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 
<filter> 
    <filter-name>charsetFilter</filter-name> 
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> 
<init-param> 
    <param-name>encoding</param-name> 
    <param-value>UTF-8</param-value> 
    </init-param> 
<init-param> 
    <param-name>forceEncoding</param-name> 
    <param-value>true</param-value> 
    </init-param> 
    </filter> 

    <filter> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
    </filter> 



<filter-mapping> 
    <filter-name>charsetFilter</filter-name> 
    <url-pattern>/*</url-pattern> 
    </filter-mapping> 
<servlet> 

<filter> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
    </filter> 

<listener> 
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> 
    </listener> 

<listener> 
    <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class> 
    </listener> 

<filter-mapping> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <url-pattern>/*</url-pattern> 
    </filter-mapping> 


    <servlet-name>KeyCard</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <load-on-startup>1</load-on-startup> 
    </servlet> 
<servlet-mapping> 
    <servlet-name>KeyCard</servlet-name> 
    <url-pattern>*.html</url-pattern> 
    </servlet-mapping> 


<session-config> 
    <session-timeout>120</session-timeout> 
    </session-config> 
<welcome-file-list> 
    <welcome-file>index.jsp</welcome-file> 
    </welcome-file-list> 
    </web-app> 
+0

請仔細閱讀你的問題,看看你能否理解它 - 我懷疑其他人會 - 你需要將xml格式化爲代碼 – Mark 2011-02-14 11:44:09

回答

0

你手工編寫該XML?

錯誤消息將告訴您XML根據該公司預計,該架構是無效的:

  1. 如果你有<filter-name>它期待的<description>之一,<display-name><icon><servlet-name>
  2. </servlet>標籤(或可能打開<servlet>)似乎是在錯誤的地方

編輯:我裝了XML的氧氣,它看起來像<servlet>的問題實際上是由於<filter>標籤剛過它是錯位的。

0

今天我遇到了類似的錯誤。我的代碼如下所示:

<servlet> 
    <init-param> 
     <param-name>data1</param-name> 
     <param-value>value1</param-value> 
    </init-param> 
    <init-param> 
     <param-name>data2</param-name> 
     <param-value>value2</param-value> 
    </init-param> 
    <servlet-name>ServletConfigServlet</servlet-name> 
    <servlet-class>com.netease.server.example.web.controller.ServletConfigServlet</servlet-class> 
</servlet> 

錯誤警告:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. 
One of '{"http://java.sun.com/xml/ns/javaee":description, 
"http://java.sun.com/xml/ns/javaee":display-name, 
"http://java.sun.com/xml/ns/javaee":icon, 
"http://java.sun.com/xml/ns/javaee":servlet-name}' is expected. 

我已經嘗試了一些解決方案。最後,我用修好了,更改了訂單<init-param><servlet-name>, <servlet-class>。它看起來像:

<servlet> 
    <servlet-name>ServletConfigServlet</servlet-name> 
    <servlet-class>com.netease.server.example.web.controller.ServletConfigServlet</servlet-class> 
    <init-param> 
     <param-name>data1</param-name> 
     <param-value>value1</param-value> 
    </init-param> 
    <init-param> 
     <param-name>data2</param-name> 
     <param-value>value2</param-value> 
    </init-param> 
</servlet> 

希望這可以幫助別人。 :D