[英]Eclipse Java EE IDE not supporting javax.servlet package
I downloaded Eclipse Java EE IDE to build Java Web Applications (servlets and JSP pages). 我下载了Eclipse Java EE IDE来构建Java Web应用程序(servlet和JSP页面)。 But it still is not supporting the
javax.servlet
package. 但它仍然不支持
javax.servlet
包。
Why? 为什么? What's the reason?
什么原因? Is there any plugin that I need to install?
我需要安装任何插件吗?
You need to integrate a servlet container in Eclipse and associate it with your Dynamic Web Project . 您需要在Eclipse中集成servlet容器并将其与Dynamic Web Project相关联。 Eclipse doesn't ship with a servlet container by default.
默认情况下,Eclipse不附带servlet容器。 You need to download and install it separately.
您需要单独下载并安装它。 A widely used one is Apache Tomcat .
广泛使用的是Apache Tomcat 。 Just download the ZIP and extract it somewhere.
只需下载ZIP并将其解压缩到某处。
Then in Eclipse, go to the Servers view in the box at the right bottom. 然后在Eclipse中,转到右下角框中的Servers视图。 Then Add a new server where in you choose Apache Tomcat 6 from the list and point the Tomcat root folder (there where you extracted it).
然后添加一个新服务器,从列表中选择Apache Tomcat 6并指向Tomcat根文件夹(在那里解压缩它)。 Then you can select it from the Target Runtime dropdown during the Dynamic Web Project creation wizard.
然后,您可以在Dynamic Web Project创建向导期间从Target Runtime下拉列表中选择它。 Or if you already have created one but didn't associate it with a server, then modify it in the Targeted Runtimes section of the project's properties.
或者,如果您已经创建了一个但未将其与服务器关联,则在项目属性的“ 目标运行时”部分中对其进行修改。 This way the server's libraries will be automagically added to the project's buildpath.
这样服务器的库将自动添加到项目的构建路径中。 That's finally also the whole point.
这也是最重要的一点。 The server is basically a concrete implementation of the abstract Servlet API.
服务器基本上是抽象 Servlet API的具体实现 。 It has all the API libraries in its
/lib
folder. 它的
/lib
文件夹中包含所有API库。
Here's a video tutorial (which does it a bit differently than above described, but it's also sufficient) and here's a text/screenshot tutorial (you can just skip the JSF part if that's not of interest yet). 这是一个视频教程 (它与上面描述的有点不同,但它也足够了)这里是一个文本/截图教程 (如果不感兴趣,你可以跳过JSF部分)。
You probably need to create a Dynamic Web Project instead of a normal Java project. 您可能需要创建动态Web项目而不是普通的Java项目。
Or you can add a server profile to your workspace, and then add the server runtime to a Java project's libraries. 或者,您可以将服务器配置文件添加到工作区,然后将服务器运行时添加到Java项目的库中。
Window -> Preferences -> Server -> Runtime Environments
. Window -> Preferences -> Server -> Runtime Environments
。 Click Add...
, choose the server type that you're using, specify the directory where that server is installed, and click Finish
. Add...
,选择您正在使用的服务器类型,指定安装该服务器的目录,然后单击“ Finish
。 Properties -> Java Build Path -> Libraries -> Add Library -> Server Runtime
, choose the server you just added from the list, and click Finish
. Properties -> Java Build Path -> Libraries -> Add Library -> Server Runtime
,从列表中选择刚刚添加的服务器,然后单击Finish
。 This will make all the server's libraries available to your project.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.