说明你用Meaven创建的WEB项目没有引入servlet-api
在你的pom.xml中加入
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
它就可以编译通过了
说明你用Meaven创建的WEB项目没有引入servlet-api
在你的pom.xml中加入
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
它就可以编译通过了