繁体   English   中英

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

[英]URL to access RESTful WebApp deployed to Tomcat 7.0

我一直在按照本教程http://www.vogella.de/articles/REST/article.html学习 RESTful Web 服务。 据我了解,访问 rest 服务的 url 是

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

并且显示名称在 web.xml 中配置。 然而实际的 url 是

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

这个对吗? 如果战争文件名还包含版本信息,url 会看起来很尴尬。 那么是否可以覆盖它?

我正在使用 Tomcat 7.0、Jersey 和 Eclipse Z581D6381F3F35E4F9D77201AC

谢谢。

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

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

否则总是:

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

但是您可以通过在 web.xml 中选择适当的上下文路径来更改此值:

就像是

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

应该产生:

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

在这里查看一些信息:

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

希望有帮助...

暂无
暂无

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

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