Mac OS下错误The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方法

在Eclipse下面开发Web项目时,会遇到上面所提到的问题,那么,怎么解决呢。

一、在Eclipse中配置Apache Tomact。

       Eclipse->Preferences->Server->Runtime Environments->add

Mac OS下错误The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方法

       此处注意,Eclipse在add时会有一个Apache的选项,但这个不是我们要选的,我们在上面的搜索框输入tomact,然后就会有各种tomact的版本信息,选择和自己电脑上面安装的版本一致的,然后再选择安装tomact的位置,然后点击apply就可以了。

二、在项目中配置Apache Tomact。

       这一步要比上一步简单。

       1)右键项目名,点击build path,然后点击configure build path

Mac OS下错误The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方法

 

选择Java build path,然后选择Libraries列,点击add library,再弹出的列表中选择Server Runtime,点击next,选择apache tomact,点击finish。

Mac OS下错误The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方法

 

Mac OS下错误The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方法

 

       2)再选择order and export列,勾选apache tomact,点击apply。到此就完成了。

Mac OS下错误The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path的解决方法

 

然后再删除原来显示错误的文件,新建一个同样的文件就不会报错了;或者关闭Eclipse重新打开项目,也可解决。