如何在 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
How to add Javadoc for Servlet API in Eclipse
提问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:如图所示,编辑按钮始终处于禁用状态!
回答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.zip
file).
在项目的 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+T或Ctrl+单击现有代码中任何进口/报关,然后单击附加源...按钮并指定它。
回答by sal
回答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
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”:
回答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.class
the given option to provide sources for my gwt-user.jar
lib confused me a little bit.
我一直在尝试以javax.
适当的方式附加libs的源代码但没有结果,直到我发现在某些情况下由于某种原因Eclipse搞乱了.jar及其类之间的关系。例如,当我点击Attach Source...为HttpServlet.class
给定的选项为我的gwt-user.jar
lib提供源时,我有点困惑。
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.0
library higher then GWT SDK
). Also at the Librariestab provide the proper sources archive for servlet-api.jar
like 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.jar
like提供适当的源存档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 在线的直接链接。