如何获取请求的 URL?

发布于 2024-09-25 11:03:02 字数 244 浏览 1 评论 0原文

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

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

我该怎么做?

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.

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

How can I do this ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿得七秒忆 2024-10-02 11:03:02

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

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

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) {
    ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文