项目使用的是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>
所有评论(0)