【解决方案】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-r

【JAVA错误】

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


【错误源码】

在springmvc 配置过程中,配置web.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></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- 配置springmvc核心控制器 -->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 再启动web容器的时候,实例化servlet对象 -->
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>configLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>

【解决方案】

错误点:

     <load-on-startup>1</load-on-startup>
<init-param>
<param-name>configLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>

将代码中

<load-on-startup>1</load-on-startup>

放在<init-param>标签之下即可:

<init-param>
<param-name>configLocation</param-name>
<param-value>classpath:springmvc.xml</param-value>
</init-param>
<!-- 关键点 -->
<load-on-startup>1</load-on-startup>
上一篇:Android学习笔记(四)


下一篇:[webkit移动开发笔记]之如何去除android上a标签产生的边框