How to add Javadoc for Servlet API in Eclipse

时光毁灭记忆、已成空白 提交于 2019-11-27 19:55:31

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).

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

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

First, download the "Full documentation" from the tomcat website. As Example for 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.

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":

And now eclipse will show you the correct Javadoc:

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 Eclipse is messing up the relationship between .jar and 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.

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

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).

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!