【问题标题】:URL to access RESTful WebApp deployed to Tomcat 7.0用于访问部署到 Tomcat 7.0 的 RESTful WebApp 的 URL
【发布时间】:2011-05-28 09:17:59
【问题描述】:

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

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

并且显示名称是在 web.xml 中配置的。但是实际的网址是

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

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

我正在使用 Tomcat 7.0、Jersey 和 Eclipse IDE。

谢谢。

【问题讨论】:

    标签: java rest tomcat


    【解决方案1】:

    这是上下文路径。 因为你可以在 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

    希望对您有所帮助...

    【讨论】:

    • 我认为您也可以在部署期间覆盖。你当然可以在 Tomcat 6 中。
    猜你喜欢
    • 2023-03-14
    • 2014-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-20
    • 1970-01-01
    • 1970-01-01
    • 2012-05-18
    相关资源
    最近更新 更多