The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案

一、问题出现

在导入Web项目时候会出现"The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path"这个错误,这是由于你导入的项目的Build Path是之前项目的服务器运行环境,需要修改成你自己的服务器的环境。

二、问题展示

这是出错时候的页面截图
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案

三、问题解决

1.打开创建新服务器的页面

流程:Windows->Preferences->Server->Runtime Environments->Add
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案

2.选择服务器的位置

选择好之后点击Finish,你的新服务器就配置好了。
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案

3.配置项目的Build Path

流程:右键项目名称->Build Path->Configure Build Path
以下是页面截图,你需要把项目之前配置的服务器运行环境都删掉。点击Add Library进入下一步。
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案
选择Server Runtime,点击Next
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案
点击Finish
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案
现在看看你的Build Path页面,服务器运行环境已经加载进来了,点击Apply And Close回到主页面。
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案

4.问题解决

此时你已经发现你的报错没有,错误顺利解决。
The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案

四、感悟及其他

1.感悟

主要就是下载项目之后,很多项目都有自己之前的环境,导入的时候,别人的运行环境已经失效。而Jsp页面运行需要依赖服务器环境当中的某些包,在你本地没有这个路径,或者没有这个包,会导致Jsp页面报警,当你配置好服务器,并且把你的项目部署到服务器上的时候,这个问题就解决了。

2.支持博主

如果您觉得本文章对您有帮助,请点赞或者支持博主一下,感谢!

The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方案