WEB项目报错
The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param,filter,filter- mapping,listener,servlet,servlet-mapping,session-config?,mime-mapping,welcome-file-list?,error-page,taglib,resource-env-ref,resource- ref,security-constraint,login-config?,security-role,env-entry,ejb-ref,ejb-local-ref)".
原因
web.xml头文件比较旧。规定了代码的书写顺序所以报错。
解决方案
按照规定的顺序写代码。或者替换头文件为其他版本。
web.xml v2.5
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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" version="2.5">
</web-app>
web.xml v3.0
<?xml version="1.0" encoding="UTF-8"?>
<web-app
version="3.0"
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_3_0.xsd">
</web-app>