2015-10-21 52 views
0

我的web.xml有一個奇怪的錯誤,儘管一切按預期工作。以下是Eclipse給出的錯誤:Spring MVC中web.xml的奇怪錯誤

cvc-complex-type.2.4.d:發現無效的內容以元素'load-on-startup'開始。預計在這一點上不會有子元素。

下面是在

<servlet> 
    <servlet-name>appServlet</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <init-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value> 
    </init-param> 
    <multipart-config> 
     <max-file-size>10485760</max-file-size> 
     <max-request-size>20971520</max-request-size> 
     <file-size-threshold>5242880</file-size-threshold> 
    </multipart-config> 
    <load-on-startup>1</load-on-startup> 
</servlet> 

發生錯誤的XML的一部分,並在<load-on-startup>1</load-on-startup>

給出錯誤的是這只是Eclipse的是陌生的情況?還是有什麼我失蹤?

這裏是案件的全部web.xml中是不相關的那部分代碼一點事都沒有

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> 
    <context-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value>/WEB-INF/spring/root-context.xml</param-value> 
    </context-param> 
    <!-- Creates the Spring Container shared by all Servlets and Filters --> 
    <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 
    <!-- Processes application requests --> 
    <servlet> 
     <servlet-name>appServlet</servlet-name> 
     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <init-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value> 
     </init-param> 
     <multipart-config> 
      <max-file-size>10485760</max-file-size> 
      <max-request-size>20971520</max-request-size> 
      <file-size-threshold>5242880</file-size-threshold> 
     </multipart-config> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>appServlet</servlet-name> 
     <url-pattern>/</url-pattern> 
    </servlet-mapping> 
</web-app> 

回答

0

更改標籤的序列。這應該沒問題。

<load-on-startup>1</load-on-startup> 
    <multipart-config> 
     <max-file-size>10485760</max-file-size> 
     <max-request-size>20971520</max-request-size> 
     <file-size-threshold>5242880</file-size-threshold> 
    </multipart-config> 
+0

謝謝!之前我曾嘗試過,但在錯誤消失之前我需要構建該項目。 –