jsp文件报错信息 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

jsp文件报错信息 The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path

 

建立了一个Javaweb工程,Jsp文件报错,并在eclipse中配置了Web容器Tomcat。原本开心的新建jsp页面,添加一个简单的Java类。可是,JSP页面顶端出现“红色”的报错信息:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path。原来Javaweb工程类中没有添加Tomcat运行时相关类导致。

下面是具体的解决方法:

1、右击web工程-》属性或Build Path-》Java Build Path->Libraries-> Add Libray...->Server Runtime -》Tomcat Server

2、切换到Java Build Path界面中的Orader and Export,选择Tomcat。

 

注意:

按以上方法操作时,若打开Server Runtime后一片空白,需要设置Apache服务器。设置方法为:window->Preferences->Server->Runtime Environment -> add --> 选择Apache的版本后点Next,再填入你apache服务器软件的安装(解压后)地址。