How do I get the URL of a request?

前端 未结 1 1092
野趣味
野趣味 2021-02-12 17:54

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.

1条回答
  •  轮回少年
    2021-02-12 18:07

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

    0 讨论(0)
提交回复
热议问题