当前位置: 代码迷 >> 综合 >> cvc-complex-type.2.4.a: Invalid content was found starting with element ...的解决方法
  详细解决方案

cvc-complex-type.2.4.a: Invalid content was found starting with element ...的解决方法

热度:97   发布时间:2023-12-06 21:50:55.0

项目使用的是Spring MVC,之前使用的 web.xml 使用的是2.4版本的,今天把它升级至2.5版本,但是升级之后,spring mvc 的 servlet 的声明报错了:

<servlet><servlet-name>apps</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><load-on-startup>5</load-on-startup><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:resources/applicationContext.xml</param-value></init-param>
</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":run-as, "http://java.sun.com/xml/ns/javaee":security-role-ref}' is expected.

这个问题怎么解决呢?其实很简单,只要将“<load-on-startup>5</load-on-startup>”调个位置就好了,见下面:

<servlet><servlet-name>apps</servlet-name><servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class><init-param><param-name>contextConfigLocation</param-name><param-value>classpath:resources/applicationContext.xml</param-value></init-param><load-on-startup>5</load-on-startup>
</servlet>

 

  相关解决方案