web.xml文件头出错

原先将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

如下所示

问题就解决了。。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值