如何获取请求的URL? [英] How do I get the URL of a request?

查看:239
本文介绍了如何获取请求的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jeresy Jax-RS构建Web服务.现在,如果存在端口号,我需要获取带有端口号的请求的网址.

I am using Jeresy Jax-RS to build a web service. Now I need to get the url of the request with the port # if one exist.

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

So if my service runs on http://www.somelocation.com/web/services I want to capture the www.somelocation.com

我该怎么做?

推荐答案

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

You can add a UriInfo parameter to your operation. From there you can access the URL:

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

这篇关于如何获取请求的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆