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

这篇短文里有两种解决方案,另外一篇短文里还有第三种解决方案,查看请点击这里

1. 报错如图:

这是错误提示:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path



2. 错误分析:

本来想着是因为缺少web容器,也就是Servlet容器。

所以我在pom.xml文件里添加了tomcat插件:

 1 <plugins>
 2     <plugin>
 3         <groupId>org.apache.tomcat.maven</groupId>
 4         <artifactId>tomcat7-maven-plugin</artifactId>
 5         <version>2.2</version>
 6         <configuration>
 7         <port>8050</port>
 8         <path>/</path>
 9         </configuration>
10     </plugin>
11 </plugins>

但问题并没有解决,还是报一样的错。



3.1 解决方案

然后尝试着在pom.xml文件里添加了:

 1 <dependency>
 2     <groupId>javax.servlet</groupId>
 3     <artifactId>servlet-api</artifactId>
 4     <version>2.5</version>
 5     <scope>provided</scope>
 6 </dependency>
 7 <dependency>
 8     <groupId>javax.servlet</groupId>
 9     <artifactId>jsp-api</artifactId>
10     <version>2.0</version>
11     <scope>provided</scope>
12 </dependency>    

错误解决了。



3.2 接着又尝试着删掉了pom.xml文件里的tomcat插件,工程依旧没有问题。

接着又尝试着删掉了pom.xml文件里的servlet.api和jsp-api。

接着右击项目-->Build Path-->Add Libraries-->Server Runtime......

也可以解决问题,工程不报错。



4. 分析 3.1、3.2 两个解决方案:

pom.xml文件里添加tomcat插件,并不会把servlet-api和jsp-api也依赖进来,所以还要手动依赖进来这两个jar包。

但通过右击项目-->Build Path-->Add Libraries-->Server Runtime......的方式添加 tomcat 的话会把 servlet API 和 jap API 也依赖进来。



5.还有第三种解决方案

请点击这里查看我的另外一篇短文。

时间: 2024-10-06 21:15:56

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path之二的相关文章

JavaWeb: 报错信息The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

JavaWeb: 报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 好久不写Jsp,今天建立了一个Javaweb工程,并在eclipse中配置了Web容器Tomcat.原本开心的新建jsp页面,添加一个简单的Java类.可是,JSP页面顶端出现“红色”的报错信息:The superclass "javax.servlet.http.HttpServl

The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 用eclipse做jsp文件,自动创立的文件表头出现这个报错,应该怎么处理?tomcat的插件已经安装上了. 有一处刚发现了,是中英文标点问题,这两处,一个是The word 'username' is not correctly spelled,还一个是The document body. Contains all

eclipse:报错信息The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

JavaWeb: 报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 今天建立了一个Javaweb工程,并在eclipse中配置了Web容器Tomcat.JSP页面顶端出现“红色”的报错信息:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Bu

eclipse中web工程新建jsp文件报错:The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

web工程中新建jsp文件提示:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 解决方案: 1.右击web工程->属性或Build Path->Java Build Path->Libraries-> Add Libray...->Server Runtime ->JBoss 7.1 Runtime   2.切换到Java Bui

eclipse新建maven项目报错The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path的解决方案

具体表现为: 使用Eclipse+Maven建立了一个Javaweb工程,JSP页面顶端出现“红色”的报错信息:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path. 解决方法: 在pom.xml中的  <build></build>中  添加: <plugins> <!-- 编码和编译和JDK版本 --> <plug

java web-The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

在静态项目上新建 jsp文件的时候,报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 这时需要在eclipse中的 windows->references->Server->Runtime Environments中添加服务器即可.

新建 jsp异常,The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

新项目,新建jsp页面的时候报异常: Multiple annotations found at this line: - The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path - The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 右

JavaWeb:报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 解决办法

JavaWeb: 报错信息The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 好久不写Jsp,今天建立了一个Javaweb工程,并在eclipse中配置了Web容器Tomcat.原本开心的新建jsp页面,添加一个简单的Java类.可是,JSP页面顶端出现"红色"的报错信息:The superclass "javax.servlet.http

eclipse中,项目有红叉之- The superclass &quot;javax.servlet.http.HttpServlet&quot; was not found on the Java Build Path

1.The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 2.原因:确实servlet-api.jar 3.导入servlet-api.jar,其中一种方法:项目右击->build path->configure build path->add library->server runtime->apache tomcat