在使用maven创建好的web项目,打开web文件添加</web-app>结束标签会报错
刚打开如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"/>加上结束标签报错:The markup in the document following the root element must be well-formed.
改动之后
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
</web-app>只需要把头文件最后的 / 去掉即可
本文介绍了解决Maven创建的Web项目中web.xml文件因格式问题导致的错误。通过去除XML文件中不规范的自闭合标签斜杠,使文件符合XML格式要求,从而消除错误。
716

被折叠的 条评论
为什么被折叠?



