The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build

有一段时间没做jsp了,今天想深入一下tomcat服务器,maven项目时,jsp的index的页面报个错:

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build

根据提示中文意思是说,javax.servlet.http.HttpServlet类在java构建时没有找到

解决方法如下:

1.选中项目名称,点击右键选择buildpath  》 config buildpath

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build

 

弹出如下对话框

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build

单击右边栏的Add Labrary,弹出如下对话框

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build

点击 Server Runtime,继续弹出下面的对话框

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build

选择配置过的http服务器,此处以tomcat为例

最后点击finish,ok项目刷新后,jsp的红色波浪线不见了,说明这个错误解决了。

 

当然还有一个更为简单的方法就是在项目pom文件中添加servelet.jar的依赖,然后刷新项目。