The superclass javax.servlet.http.HttpServlet was not found on the Java Buid Path

jsp顶部出现The superclass javax.servlet.http.HttpServlet was not found on the Java Buid Path

The superclass javax.servlet.http.HttpServlet was not found on the Java Buid Path

解决方法:

  1. 错误:
    项目中某一.jps页面忽然出现错误,鼠标点上去为:The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path.
    忽视错误,在Eclipse下启动tomcat的时候,报错为:Eclipse下启动tomcat报错:The archive: D:/Program Files/apache-tomcat-7.0.52/bin/bootstrap.jar which is referenced by the classpath, does not exist.

  2. 查找原因:
    原本我的Tomcat路径为:D:\Program Files\apache-tomcat-7.0.52\,后来由于重装系统,改为:D:\ProgramFiles\apache-tomcat-7.0.52\,在报错中可以发现是缺少servlet-api.jar,也即tomcat路径问题。

  3. 尝试解决:
    ①.
    1.右键点击项目->build path->configure build path->add library->server runtime->apache tomcat
    无果,无法添加。
    ②.
    1.打开Eclipse中tomcat配置,就是双击server选项卡中的tomcat,然后选择openlaunch configuration,如下图所示:
    解决方法:
    1.错误:
    项目中某一.jps页面忽然出现错误,鼠标点上去为:The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path.
    忽视错误,在Eclipse下启动tomcat的时候,报错为:Eclipse下启动tomcat报错:The archive: D:/Program Files/apache-tomcat-7.0.52/bin/bootstrap.jar which is referenced by the classpath, does not exist.
    2.查找原因:
    原本我的Tomcat路径为:D:\Program Files\apache-tomcat-7.0.52\,后来由于重装系统,改为:D:\ProgramFiles\apache-tomcat-7.0.52\,在报错中可以发现是缺少servlet-api.jar,也即tomcat路径问题。
    3.尝试解决:
    ①.
    1.右键点击项目->build path->configure build path->add library->server runtime->apache tomcat
    无果,无法添加。
    ②.
    1.打开Eclipse中tomcat配置,就是双击server选项卡中的tomcat,然后选择openlaunch configuration,如下图所示:The superclass javax.servlet.http.HttpServlet was not found on the Java Buid Path
    2.打开以后会出现如下界面:
    The superclass javax.servlet.http.HttpServlet was not found on the Java Buid Path
    3.如上图所示,将错误路径删除,并保证正确配置tomcat-juli.jar和bootstrap.jar这两个jar包的路径。
    无果,修改后仍启动不了Tomcat。
    ③.
    1.在server选项卡中删除所有server,新建tomcat。
    无果,无法新建。
    ④.
    1.退出 eclipse
    2.到[工程目录下]/.metadata/.plugins/org.eclipse.core.runtime
    3.把org.eclipse.wst.server.core.prefs和 org.eclipse.jst.server.tomcat.core.prefs这两个文件去掉
    4.重启eclipse
    无果,没找到org.eclipse.wst.server.core.prefs和 org.eclipse.jst.server.tomcat.core.prefs这两个文件。
    ⑤.
    1.在Eclipse中,Window–>preference --> servers --> runtime --> environments --> 全部删除

    2.Add–>Browse–>选择本地tomcat文件夹所在位置–>确定 --> finish–>OK
    成功!

  4. 结论:
    实际上是preference中路径错误的问题,直接删除掉server再重建的方法不行。
    以后在移动相关资源或者依赖资源的时候会对原有的依赖它的项目产生影响。尽量将自己的IDE和相关的环境固定,少做更改,减少那些隐藏的错误出现的几率。