Eclipse中编写JSP文件时报错 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build P

时间:2021-03-16 15:53:59

Eclipse中编写JSP文件报错 The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
意思是没有找到 HttpServlet这个父类。原因是没有配置好Tomcat,至少我是这个原因。虽然我们已经安装好Tomcat,但是还没配置好,所以报错。
解决的步骤:Windows–>Preference–>Server–>Runtime Enviromments –>右边栏add

Eclipse中编写JSP文件时报错 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build P

Eclipse中编写JSP文件时报错 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build P

点击右侧的add ,然后选择自己安装的Tomcat对应版本
Eclipse中编写JSP文件时报错 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build P

Eclipse中编写JSP文件时报错 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build P

选择你的Tomcat的安装目录,最后finish。
Eclipse中编写JSP文件时报错 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build P

接着就是为我们的项目配置一下:
右键我们的项目,选择最下面的properties:

Eclipse中编写JSP文件时报错 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build P

在弹出的页面中选择Libraries –>add library ,然后还会弹出一个页面,在新页面中选择Server Runtime 如下图右侧
Eclipse中编写JSP文件时报错 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build P

接着弹出下面图片:
然后选择我们前面配置好的Tomcat ,最后finish 即可。
Eclipse中编写JSP文件时报错 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build P

到此,这个小 BUG算是解决了。