jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题

相信大家在eclipse上信心满满写完一个jsp文件时,肯定希望在server上运行出来并进行修改,但是有时候,一些我们不知道的问题总是不能让我们如愿,如下图所示 jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题

这是我在eclipse中新建的一个jsp文件,作用是在网页中显示Hello World,但不知道为什么会出现这样的问题,一开始,我以为是第一行的问题,于是,我把第一行删除了
jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
好吧,我就知道没这么简单!!!,根据提示是配置Java Build Path的配置问题,于是在在出现此错误的项目上单击鼠标右键>Build Path>Configure Build Path,进入配置界面
jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
可是之后怎么办呢,该怎么配置呢,在网上找了相关的教程后,发现是缺少了Apache Tomcat,于是我赶紧添加,点击Library>点击Server Runtime>选择Next>
jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
发现没有可供选择的Tomcat Server
jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
这时,有些小伙伴肯定慌了,以为要自己没有下载Tomcat Server,又要到某个官网去下某些看也看不懂的Tomcat Server组件,别慌,我这就来帮你解决问题

  1. 选择 eclipse 的WIndows菜单>Preferences 预设
    MacOS 下是 Eclipse 菜单>偏好设置
    jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
  2. 在左侧列表中找到 Server 项,展开,选中RuntimeEnvironments,右侧点击添加按钮
    jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
  3. 在搜索框中输入Tomcat,搜索根据你自己的Java EE版本并选择相应的Apache Tomcat,我这里选择的是Apache Tomcat v9.0
    jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
    单击Next>,并选择相应的Browse…,就是你的Tomcat放置的位置
    jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
    如果你还没有安装 Tomcat,那可以去官网下载一个压缩包解压到一个目录就可以了。如果实在不会下载,这里有我下载的tomcat9链接: https://pan.baidu.com/s/1UxrnfXpllwemKQvdimtdhg
    提取码: 754b
  4. 完成后单击Finish保存退出即可
    jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
    发现没有问题了

我们运行试试,在代码任意处右击选择Run As>Run on Server
jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
单击Finish,静静等待结果出现
jsp文件出现The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path问题
成功了,真令人感到兴奋!!!