帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path

问题描述:

eclipse创建maven 的 webapp项目,创建完就报错的
报的是

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_第1张图片

原因分析:

说实话,我也不知道这算是个什么问题。但是你看着行报错
它说
javax.servlet.http.HttpServlet这个东西在 Build Path 里面找不到。

解决方案:

所以解决方法就有两种了

第一种

我感觉这种方式比较简单,直接在pom.xml中加个依赖

   
                javax.servlet 
                servlet-api 
                2.5 
                provided 
                
  

然后保存更新,ok,问题就解决了

第二种

这种方式必须先安装好Tomcat,且在eclipse配置好tomcat
假设eclipse还没配置的话,你看到的情况是这样的
右击工程->Build path->Configure Build Path
帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path_第2张图片
libraries->add Library->server Runtime
帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path_第3张图片
如果没有配置tomcant,你看到的就是空空如也
帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path_第4张图片
这时候你没安装Tomcat的话先按装下Tomcat
然后配置
配置如下
1.打开Eclipse,Window–>Preference
帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path_第5张图片
–>Server–>Runtime Environments-》add
这里因为我的tomcat版本是7.0.94所以我选7.0,
next
帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path_第6张图片
选一下tomcat安装目录-finish
帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path_第7张图片
applyandclose
帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path_第8张图片
这时候再右击工程->Build path->Configure Build Path
帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path_第9张图片
libraries-addLibrary-serverruntime-next
帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path_第10张图片
此时就可以看到你的tomcat,你加进来,最后applyandcose就可以了
帮小白解决问题---------The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path_第11张图片
问题解决,拜拜

你可能感兴趣的:(帮小白解决问题,The,superclass,eclipse,tomcat)