今天在IDEA中使用maven新建一个项目的时候,在web.xml中添加多个servlet标签,web-app出现报错(加一个并不报错):
之后发现原因是:我在pom.xml中引入的servlet包的版本是4.0,与我默认的web.xml的版本不匹配:
所以只需要在web.xml中在web-app的头部加入如下配置,保证servlet版本与web.xml版本相匹配:
<web-app 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_4_0.xsd"
version="4.0">