eclipse 在 Java 构建路径上找不到超类“javax.servlet.httpServlet”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38991878/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:15:51  来源:igfitidea点击:

the superclass "javax.servlet.httpServlet" was not found on the Java Build Path

eclipsejsptomcatservlets

提问by Tour4x

I have get a problem when I create a new web project in the eclipse.
There show 'the superclass "javax.servlet.httpServlet" was not found on the Java Build Path'.
I have find solution on the Internet, but that not work.
The solution is Project Properties-> Java Build Path-> Add Library -> Select "Server Runtime" from the list-> Next->Select "Apache Tomcat"-> Finish.
Is there anybody can give me other solution? Thanks very much.
My OS is macOS,tomcat is 9.0.0.M9,jdk is 1.8.0_101,the eclipse is jee-neon.

在 Eclipse 中创建新的 Web 项目时遇到问题。
那里显示“在 Java 构建路径上找不到超类“javax.servlet.httpServlet”。
我在互联网上找到了解决方案,但不起作用。
解决方法是Project Properties->Java Build Path->Add Library->从列表中选择“Server Runtime”->Next->选择“Apache Tomcat”->Finish。
有没有人可以给我其他解决方案?非常感谢。
我的操作系统是macOS,tomcat是9.0.0.M9,jdk是1.8.0_101,eclipse是jee-neon。

回答by javailike

I have solved the problem by doing the following,

我已经通过执行以下操作解决了这个问题,

Actually i got this error, my scenario was..

实际上我遇到了这个错误,我的情况是..

I was using the APACHE TOMCAT SERVER VERSION 8.0, but the project i downloaded was using APACHE TOMCAT VERSION 7.0 it seems, so i changed it to version 8.

我使用的是 APACHE TOMCAT SERVER VERSION 8.0,但我下载的项目似乎使用的是 APACHE TOMCAT VERSION 7.0,所以我将其更改为版本 8。

How was did was:

是怎么做的:

  1. right Click on the Project properties.
  2. In the Left menu, we can see the Java Build Path
  3. Select the Library tab, and add the new Library.
  4. In the Library Type, select the Server Run time, then click next and Finish will solve the problem.
  1. 右键单击项目属性。
  2. 在左侧菜单中,我们可以看到 Java Build Path
  3. 选择库选项卡,然后添加新库。
  4. 在库类型中,选择服务器运行时间,然后单击下一步,完成将解决问题。

All the Best

祝一切顺利

回答by thangaraj

I tried above steps and still errors were there in JSP even runtime libraries were configured properly. I'm using java 8 and tomcat 8. So I unchecked "validate jsp fragments" under project properties > validation > jsp syntax.

我尝试了上述步骤,但即使正确配置了运行时库,JSP 中仍然存在错误。我正在使用 java 8 和 tomcat 8。所以我在项目属性 > 验证 > jsp 语法下取消选中“验证 jsp 片段”。

回答by Ehsan

With using Eclipse:

使用 Eclipse:

Version: Oxygen.2 Release (4.7.2)
Build id: 20171218-0600

I solved the Tomcat Server Library import as follows:

我解决了Tomcat服务器库导入如下:

  1. Right Click on the Project properties.
  2. In the Left menu, we can see the Java Build Path.
  3. Select the Librariestab, and Add Librarybutton.
  4. In the Add Librarywindow, select the Server Runtimein the list.
  5. Click on Nextbutton, Select the item Apache Tomcatmentioned with version in the list, and click on Finishbutton.
  1. 右键单击Project properties
  2. 在左侧菜单中,我们可以看到Java Build Path.
  3. 选择Libraries选项卡和Add Library按钮。
  4. Add Library窗口中,选择Server Runtime列表中的 。
  5. 单击Next按钮,Apache Tomcat在列表中选择版本中提到的项目,然后单击Finish按钮。

Wish it makes smile on your face!

希望它能让你的脸上露出笑容!