简体   繁体   English

URL 以访问部署到 Tomcat 7.0 的 RESTful WebApp

[英]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 .我一直在按照本教程http://www.vogella.de/articles/REST/article.html学习 RESTful Web 服务。 As I understand, the url to access the rest service is据我了解,访问 rest 服务的 url 是

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

and that the display-name is configured in web.xml.并且显示名称在 web.xml 中配置。 However the actual url is然而实际的 url 是

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.如果战争文件名还包含版本信息,url 会看起来很尴尬。 So is it possible to override this?那么是否可以覆盖它?

I am using Tomcat 7.0, Jersey and Eclipse IDE.我正在使用 Tomcat 7.0、Jersey 和 Eclipse Z581D6381F3F35E4F9D77201AC

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因为你可以在 tomcat 中有多个上下文,每个上下文都必须有自己的上下文路径,默认情况下 tomcat 使用 war 文件名前缀,但如果你部署在 tomcat 的 ROOT webapp 目录中,你可以访问你的 webapp

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:但是您可以通过在 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 http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Attributes

hope that helped...希望有帮助...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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