在pom.xml配置文件中添加上javax.servlet的相關依賴:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
依賴tomcat類庫:
項目右擊—>build path —> configure build path — >libraries — > add libraries —> Server Runtime — >選擇tomcat —> ok