Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc Spring MVC中web.xml出现奇怪错误_Spring Mvc - Fatal编程技术网

Spring mvc Spring MVC中web.xml出现奇怪错误

Spring mvc Spring MVC中web.xml出现奇怪错误,spring-mvc,Spring Mvc,我的web.xml有一个奇怪的错误,尽管一切都按预期进行。以下是Eclipse给出的错误: cvc复杂类型.2.4.d:发现以元素“启动时加载”开头的无效内容。此时不需要任何子元素 以下是发生错误的xml部分 <servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServle

我的web.xml有一个奇怪的错误,尽管一切都按预期进行。以下是Eclipse给出的错误:

cvc复杂类型.2.4.d:发现以元素“启动时加载”开头的无效内容。此时不需要任何子元素

以下是发生错误的xml部分

<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>

appServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/spring/appServlet/servlet-context.xml
10485760
20971520
5242880
1.
并且错误出现在
1

这只是日食奇怪的一个例子吗?还是我遗漏了什么

这里是完整的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>

上下文配置位置
/WEB-INF/spring/root-context.xml
org.springframework.web.context.ContextLoaderListener
appServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/spring/appServlet/servlet-context.xml
10485760
20971520
5242880
1.
appServlet
/

更改标签的顺序。这应该没问题

 <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> 
1
10485760
20971520
5242880

谢谢!我以前试过,但我需要在错误消失之前构建项目。