开发者

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_r开发者_如何学JAVAest_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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜