简体   繁体   中英

How do I get the URL for a Java Jersey Client request?

Using Jersey in Java I have a response object

Client c=Client.create();
WebResource r = c.resource("http://example.com/path");

MultivaluedMap<String, String> params = new MultivaluedMapImpl();
    params.add("param1", value);

r=r.path(getQualifiersByPromoServicePath).queryParams(params);

ClientResponse response = r.accept(MediaType.APPLICATION_JSON_TYPE).get(ClientResponse.class);

How can I get the url used to make the request? (for debug purposes) ie i want to get the string "http://example.com/path?param1= value " ?

Have you tried r.getURI(); ? Should be what you're looking for...

Use a Logging Filter and direct it's output to System.out for debugging purposes.

Right after instantiating your client add the following line:

c.addFilter(new LoggingFilter(System.out));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM