简体   繁体   中英

URL to access RESTful WebApp deployed to Tomcat 7.0

I have been learning RESTful webservices following this tutorial http://www.vogella.de/articles/REST/article.html . As I understand, the url to access the rest service is

http://your_domain:port/display-name/url-pattern/path_from_rest_class

and that the display-name is configured in web.xml. However the actual url is

http://your_domain:port/**war_fileneme**/url-pattern/path_from_rest_class

Is this correct? the url would look awkward if war filename also contained version info. So is it possible to override this?

I am using Tomcat 7.0, Jersey and Eclipse IDE.

Thanks.

this is the context path. since you can have multiple contexts in tomcat, each one has to have its own context path, and by default tomcat uses the war filename prefix, but if you deploy in tomcat's ROOT webapp directory you can access your webapp at

http://your_domain:port/display-name/url-pattern/path_from_rest_class

otherwise it's always:

http://your_domain:port/context/display-name/url-pattern/path_from_rest_class

but you can alter this value by choosing an apppropriate context path in web.xml:

something like

<context path="mypath">
 ...
</context>

should yield:

http://your_domain:port/mypath/display-name/url-pattern/path_from_rest_class

check here for some info:

http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Attributes

hope that helped...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM