cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'.
笔者最近学习一些spring mvc,在复制别人代码的时候报这个错。报错来源web.xml,原因是不符合xsd对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"> <servlet>
<!--名称 -->
<servlet-name>springmvc</servlet-name>
<!-- Servlet类 -->
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 启动顺序,数字越小,启动越早 -->
<load-on-startup>1</load-on-startup>
<init-param>
<!--SpringMVC配置参数文件的位置 -->
<param-name>contextConfigLocation</param-name>
<!--默认名称为ServletName-servlet.xml -->
<param-value>classpath*:springmvc-servlet.xml</param-value>
</init-param>
</servlet> <!--所有请求都会被springmvc拦截 -->
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> </web-app>
解决方法:
调整<load-on-startup>节点的顺序,放到</servlet>之前,修改后的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"> <servlet>
<!--名称 -->
<servlet-name>springmvc</servlet-name>
<!-- Servlet类 -->
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<!--SpringMVC配置参数文件的位置 -->
<param-name>contextConfigLocation</param-name>
<!--默认名称为ServletName-servlet.xml -->
<param-value>classpath*:springmvc-servlet.xml</param-value>
</init-param>
<!-- 启动顺序,数字越小,启动越早 -->
<load-on-startup>1</load-on-startup>
</servlet> <!--所有请求都会被springmvc拦截 -->
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping> </web-app>
cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'.的更多相关文章
- Type cvc-complex-type.2.4.a: Invalid content was found starting with element 'build'.错误的解决方法
项目突然间爆出了这样的问题: Description Resource Path Location Typecvc-complex-type.2.4.a: Invalid content was fo ...
- cvc-complex-type.2.4.a: Invalid content was found starting with element
在写xml的时候又一次总是报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 ‘init-param’(转)
在写xml的时候又一次总是报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 '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 o ...
- web.xml文件报错:cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'.
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" ...
- Invalid content was found starting with element 'taglib'”
今天在使用struts-menu制作菜单,在web.xml中写入 <taglib> <taglib-uri>/WEB-INF/struts-menu.tld</ ...
- 异常:cvc-complex-type.2.4.a: Invalid content was found starting with element
web.xml 出现cvc-complex-type.2.4.a: Invalid content was found starting with element <web-app xmlns= ...
- shiro中async-supported报错 cvc-complex-type.2.4.a: Invalid content was found starting with element 'async-supported'. One of '{"http://java.sun.com/xml/ns/ javaee":init-param}' is expected.
最近都在研究shiro这个框架,今天实施了一下,就报了如下错误: cvc-complex-type.2.4.a: Invalid content was found starting with ele ...
- cvc-complex-type.2.4.a: Invalid content was found starting with element 'display-name'
cvc-complex-type.2.4.a: Invalid content was found starting with element 'display-name'. One of '{&qu ...
- web.xml报错:cvc-complex-type.2.4.a: Invalid content was found starting with element 'async-supported'. One of '{"http://java.sun.com/xml/ns/javaee":init-param}' is expected.
在写xml的时候又一次总是报cvc-complex-type.2.4.a: Invalid content was found starting with element 错误,还出现小红叉,在网上找 ...
随机推荐
- 第3章 文件I/O(5)_五种I/O模型
6. I/O处理方式(5种I/O模型) 6.1 几个概念的辨析 (1)同步和异步 ①是访问数据的方式,主要是针对IO(资源.数据)而言的.关键在于I/O操作完成后,有没有提供通知机制. ②同步的IO, ...
- css border-bottom(指定下边线的样式、宽度及颜色)
border-bottom(指定下边线的样式.宽度及颜色) border-bottom: 值: border-bottom-style:值; border-bottom-color: 值; borde ...
- 《Linux内核精髓:精通Linux内核必会的75个绝技》一HACK #19 ext4的调整
HACK #19 ext4的调整 本节介绍可以从用户空间执行的ext4调整.ext4在sysfs中有一些关于调整的特殊文件(见表3-6).使用这些特殊文件,就不用进行内核编译.重启,直接从用户空间确认 ...
- 通过yum升级gcc/g++至版本4.8.2
最近在坐一个日期处理的问题,需要安装sxtwl模块,但是gcc版本4.7死活也安装不上,最后测试到只能升级gcc版本到4.8才得以解决 [root@123 bin]# gcc -vUsing buil ...
- sql上下级关系查询
有一张存在上下级关系的function表,parentId表示上级Id,现要查询出上级菜单下的子菜单,每个子菜单显示成以逗号分隔的字符串 表结构如下: create table menu ( id i ...
- Data Provider 中没有.net framework Data provider for Mysql 的解决方法
近来做的一个项目中,数据库用的是 MySql, 而在项目使用 Entity Data Model 来做数据服务层,可是在项目中添加 Data Entty Model 时,一般我们都会选择从数据库中直接 ...
- 关于生成器---(yield)
生成器:是自定义的迭代器(自己用python代码写的迭代器),函数中见到yield的就是生成器 那么yield前后的变量又该怎么理解 看例子一 def counter(name): print('%s ...
- 查看虚拟机CENTOS7 的 IP 地址和命令
用于生产环境下 安装CENTOS7 太费时间, 研究阶段 放在虚拟机里面 是最好的选择: 但是安装完毕后 就出现问题 无法使用IFCONFIG : 毕竟 内核不一样 首先我们登录操作系统 用 ...
- oracle一个用户操作多个表空间中表的问题
首先,授权给指定用户. 一个用户的默认表空间只能有一个,但是你可以试下用下面的语句为其授权在别的表空间中创建对像: alter user username quota 0||unlimited on ...
- JAVA JDBC 简单的增删改查
package jdbc_util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Prepar ...