Maven项目下的index.jsp文件报错

来源:互联网 发布:virtualbox拖拽文件mac 编辑:程序博客网 时间:2024/05/22 13:16

错误提示:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path


原因:Javaweb工程类中没有添加Tomcat运行时相关类导致的。


解决办法:

第一种:不进行tomcat的加载,而是在pom.xml中加入jar的依赖。

加入代码如下:

<dependency><groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId><version>2.5</version><scope>provided</scope></dependency>

第二种:(未尝试过,参考网上教程)

出错的文件---->>build path---->>config build path---->>java build path---->>libraries

---->>add library---->>server runtime---->>tomcat8.0 ---->>finish