原先将web.xml文件头设置为如下格式

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">

但在编译时就报错:

Multiple annotations found at this line:
- cvc-complex-type.2.3: Element 'web-app' cannot
have character [children], because the type's content type is
element-only.
- No grammar constraints (DTD or XML Schema)
referenced in the document.

如下图:

据查是文件头有错误,换个就可以了,可这个文件头是我从tomcat文件夹下的web.xml中拷贝的,相对于换一个文件头,我更倾向于从自身上找原因。。

下面简要说明不换文件头也可以改正错误的方法。

首先说第二条错误- No grammar constraints (DTD or XML Schema) referenced in the document.

解决办法是。。。。ctrl+s,这确实是我的疏忽。。滑稽脸

针对第一条:- cvc-complex-type.2.3: Element 'web-app' cannot have character [children], because the type's content type is 
element-only.

解决办法是:将<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" ...中的javaee改为j2ee

如下所示

问题就解决了。。

web.xml文件头出错的更多相关文章

  1. web.xml文件头声明各个版本参考

    Servlet 3.1 Java EE 7 XML schema, namespace is http://xmlns.jcp.org/xml/ns/javaee/ <web-app xmlns ...

  2. web.xml 文件头

    Servlet 2.3 <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN ...

  3. applicationContext.xml 文件头报错Referenced file contains errors

    问题如下:原先运行正常的项目,突然在applicationContext.xml 文件头报错 内容:Referenced file contains errors (http://www.spring ...

  4. eclipse快速配置spring相关xml文件头信息

    通过spring tools 插件工具来快速配置xml头信息 ctrl +n 创建-----------> 输入spring 选中spring Beann Configuration File ...

  5. xml文件头文件生成策略以及导入约束条件

    约束的作用是对配置文件的一种检验 约束条件分为schema约束和DTD约束,schema约束是还有目录结构,DTD约束没有目录结构 这里暂先介绍schema约束的导入 约束的分类: 1.schema ...

  6. *Mapper.xml文件头

    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-// ...

  7. Mybatis mapper.xml文件头文件备份

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-/ ...

  8. spring一个标准的xml文件头

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  9. web.xml配置Servlet出错(DispatcherServlet)

    想当然的把servlet-mapping当成servlet的属性 后台也不报错,但是输入url,就是死活不执行那个servlet servlet和servlet-mapping是同一级的对象

随机推荐

  1. Dom4j学习笔记

    一.Loading XML Data 以下代码从File中或一个URL中读取一个XML文件,并产生一个Document对象.一个Document对象表示了内存中的一棵XML树,可以在这个XML树中进行 ...

  2. 对只转发结果集的无效操作:last

    调用时候发生这样一个错误: SQLException: 对只转发结果集的无效操作:last 原因是按照缺省方式打开的ResultSet不支持结果集cursor的回滚 如果想要完成上述操作,要在生成St ...

  3. WebService—CXF整合Spring实现接口发布和调用过程

    一.CXF整合Spring实现接口发布 发布过程如下: 1.引入jar包(基于maven管理) <!-- cxf --> <dependency> <groupId> ...

  4. 似然和对数似然Likelihood & LogLikelihood

    One of the most fundamental concepts of modern statistics is that of likelihood. In each of the disc ...

  5. 第九章 Redis过期策略

    注:本文主要参考自<Redis设计与实现> 1.设置过期时间 expire key time(以秒为单位)--这是最常用的方式 setex(String key, int seconds, ...

  6. 第一章 Java代码执行流程

    说明:本文主要参考自<分布式Java应用:基础与实践> 1.Java代码执行流程 第一步:*.java-->*.class(编译期) 第二步:从*.class文件将其中的内容加载到内 ...

  7. [转贴] 数字证书及 CA 的扫盲介绍

    [略有删节] 为了达到普及的效果,俺会尽量用比较浅显,非技术的语言来讲清楚. ★先说一个通俗的例子 考虑到证书体系的相关知识比较枯燥.晦涩.俺先拿一个通俗的例子来说事儿.   ◇普通的介绍信 想必大伙 ...

  8. https://leetcode-cn.com/

    https://leetcode-cn.com/ 码,马不停蹄,码不停题 英文版:https://leetcode.com/

  9. PHP经典项目案例-(一)博客管理系统5

    本篇实现发表博客. 八.发表博客 (1).界面实现file.php <tr>      <td colSpan=3 valign="baseline" style ...

  10. C#(wpf)迷你词典

    本周利用空余时间做的一个单词查询软件(C#(Wpf)-WebService),目前只支持中英文查词,同义词.例句.发音. 未激活状态 WebService:http://fy.webxml.com.c ...