javax.servlet.* 无法解析为类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24456446/
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-08-14 12:19:30  来源:igfitidea点击:

javax.servlet.* cannot be resolved to a type

javaeclipseservlets

提问by Chinmaya B

I am running ubuntu 14.04 and eclipse Kepler (with java ee modules preloaded) , I am developing Dynamic Web App for first time, it always says javax.servlet.xyz cannot be resolved to a type please help I am including a screen snapshot for my error page!

我正在运行 ubuntu 14.04 和 eclipse Kepler(预加载了 java ee 模块),我是第一次开发动态 Web 应用程序,它总是说 javax.servlet.xyz 无法解析为类型,请帮助我为我的屏幕截图错误页面!

System Snapshot

系统快照

采纳答案by Mandar Pandit

Only two things are required in Eclipse for this:

为此,在 Eclipse 中只需要两件事:

One

In Eclipse, Window -> Preferences -> Server -> Runtime Environment
Specify your Web Server or Application Server path, by adding a "New Server Runtime Environment".

在 Eclipse 中,Window -> Preferences -> Server -> Runtime Environment
通过添加“New Server Runtime Environment”指定您的 Web 服务器或应用程序服务器路径。

Update

更新

Initially, there are only few Server Runtime Environments available with Eclipse like:

最初,Eclipse 中只有少数服务器运行时环境可用,例如:

  1. Apache
  2. Basic
  3. ObjectWeb
  1. 阿帕奇
  2. 基本的
  3. 对象网

On an additional note, you can add more Server Adapters using the link Download additional server adaptersin Server Runtime Environmentsdialog screen.

在附加的注释,你可以使用链接添加更多的服务器适配器Download additional server adapters服务器运行时环境的对话屏幕。

Server Runtime ENvironment List in Eclipse Preferences

Eclipse 首选项中的服务器运行时环境列表

Two

In Project Properties (Right Click on Project -> Properties), in Java Build Path, add Library "Server Runtime".
On adding Server Runtime to Project Library will add servlet-api.jarand jsp-api.jarjars to project dependencies.

在 Project Properties 中(右键单击 Project -> Properties),在 Java Build Path 中,添加 Library "Server Runtime"
在添加服务器运行时到项目库将增加servlet-api.jarjsp-api.jar罐子到项目的依赖。

Add Server Runtime Library to Project

将服务器运行时库添加到项目