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...
精彩评论