如何在 Eclipse 中为 Servlet API 添加 Javadoc

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

How to add Javadoc for Servlet API in Eclipse

eclipsetomcatservletsjavadoc

提问by Muhammad Hewedy

I've a dynamic web app in Eclipse that is using Tomcat as runtime environment.

我在 Eclipse 中有一个动态 Web 应用程序,它使用 Tomcat 作为运行时环境。

I cannot add Javadoc path Tomcat Servlet API: as appears, the edit button is always disabled!

我无法添加 Javadoc 路径 Tomcat Servlet API:如图所示,编辑按钮始终处于禁用状态!

alt text http://filaty.com/i/1005/80306/tom.JPG

替代文字 http://filaty.com/i/1005/80306/tom.JPG

回答by BalusC

In Package Explorer of your project go to Java Resources > Libraries. Rightclick servlet-api.jar, choose Propertiesand specify the source location there (the apache-tomcat-x.x.x-src.zipfile).

在项目的 Package Explorer 中,转到Java Resources > Libraries。右键单击servlet-api.jar,选择“属性”并在那里指定源位置(apache-tomcat-x.x.x-src.zip文件)。

Another way is to just open any Servlet API class using Ctrl+Shift+Tor by Ctrl+Click on any import/declaration in existing code and then click the Attach Source...button and specify it there.

另一种方法是只要打开使用任何Servlet API的类Ctrl+ Shift+TCtrl+单击现有代码中任何进口/报关,然后单击附加源...按钮并指定它。

回答by sal

You could download the source jars for the servlet api from Mavenand either build your own javadoc jar or just use the sources.

您可以从Maven下载 servlet api 的源 jar,然后构建您自己的 javadoc jar 或仅使用源。

回答by geistLich

First, download the "Full documentation" from the tomcat website. As Example for tomcat 8.5.23: https://tomcat.apache.org/download-80.cgi

首先,从 tomcat 网站下载“完整文档”。以 tomcat 8.5.23 为例:https://tomcat.apache.org/download-80.cgi

tomcat full documantation

tomcat 完整文档

You'll get a tar.gz file which you have to unzip since eclipse only can read folders or zip / jar.

您将获得一个 tar.gz 文件,您必须将其解压缩,因为 eclipse 只能读取文件夹或 zip/jar。

Second, set in your Java Build Path the Javadoc location for library Tomcat and "servlet-api.jar". Point to the folder "(...)\tomcat-8.5-doc\servletapi":

其次,在您的 Java 构建路径中设置库 Tomcat 和“servlet-api.jar”的 Javadoc 位置。指向文件夹“(...)\tomcat-8.5-doc\servletapi”:

eclipse tomcat servlet-api.jar

eclipse tomcat servlet-api.jar

And now eclipse will show you the correct Javadoc: enter image description here

现在 eclipse 将向您显示正确的 Javadoc: 在此处输入图片说明

回答by vitrums

I've been continuously trying to attach the sources for javax.libs in a proper way with no result, until I found that in some cases by some reason Eclipseis messing up the relationship between .jarand its classes. E.g. when I clicked upon Attach Source...for the HttpServlet.classthe given option to provide sources for my gwt-user.jarlib confused me a little bit.

我一直在尝试以javax.适当的方式附加libs的源代码但没有结果,直到我发现在某些情况下由于某种原因Eclipse搞乱了.jar及其类之间的关系。例如,当我点击Attach Source...HttpServlet.class给定的选项为我的gwt-user.jarlib提供源时,我有点困惑。

Hence one may try to play with the precedence of his libs at Project > Properties > Java Build Path > Order and Exportto put your kit over the rest (e.g. put Apache Tomcat v7.0library higher then GWT SDK). Also at the Librariestab provide the proper sources archive for servlet-api.jarlike apache-tomcat-7.0.22-src.zip. Magically the problem is solved after all.

因此,您可以尝试在Project > Properties > Java Build Path > Order and Export中使用他的库的优先级,将您的工具包放在其余部分(例如,将Apache Tomcat v7.0库放在更高的位置GWT SDK)。同样在“库”选项卡中,为servlet-api.jarlike提供适当的源存档apache-tomcat-7.0.22-src.zip。神奇的是,问题最终解决了。

回答by vitrums

In Package Explorer of your project go to Java Resources > Libraries. Rightclick servlet-api.jar, choose Properties and specify the source location there (the apache-tomcat-x.x.x-src.zip file).

在项目的 Package Explorer 中,转到 Java 资源 > 库。右键单击 servlet-api.jar,选择 Properties 并在那里指定源位置(apache-tomcat-xxx-src.zip 文件)。

or

或者

In Package Explorer of your project go to Java Resources > Libraries. Rightclick servlet-api.jar, choose Properties and specify the source location there (http://docs.oracle.com/javaee/7/api/). This will give a direct link to the api online.

在项目的 Package Explorer 中,转到 Java 资源 > 库。右键单击 servlet-api.jar,选择 Properties 并在那里指定源位置 ( http://docs.oracle.com/javaee/7/api/)。这将提供到 api 在线的直接链接。