How do I get the URL of a request?

蓝咒 提交于 2019-12-21 07:22:02

问题


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 ?


回答1:


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) {
    ...
}


来源:https://stackoverflow.com/questions/3834108/how-do-i-get-the-url-of-a-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!