【问题标题】:How do I get the URL of a request?如何获取请求的 URL?
【发布时间】:2010-09-30 19:28:06
【问题描述】:

我正在使用 Jeresy Jax-RS 构建 Web 服务。现在我需要获取带有端口号的请求的 url(如果存在)。

因此,如果我的服务在 http://www.somelocation.com/web/services 上运行,我想捕获 www.somelocation.com

我该怎么做?

【问题讨论】:

    标签: java jersey jax-rs


    【解决方案1】:

    您可以在操作中添加 UriInfo 参数。从那里您可以访问 URL:

    @POST
    @Consumes({"application/xml", "application/json"})
    public Response create(@Context UriInfo uriInfo, Customer customer) {
        ...
    }
    

    【讨论】:

      猜你喜欢
      • 2020-03-22
      • 1970-01-01
      • 2014-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多