Jersey: Print the actual request

后端 未结 4 653
-上瘾入骨i
-上瘾入骨i 2020-11-28 22:50

How can I view the actual request that Jersey generates and sends to the server? I am having issues with a particular request and the fellow running the webserver asked to

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 23:27

    If you're just using Jersey Client API, LoggingFilter (client filter) should help you:

    Client client = Client.create();
    client.addFilter(new LoggingFilter(System.out));
    WebResource webResource = client.resource("http://localhost:9998/");
    ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON)
                                             .get(ClientResponse.class);
    

    Otherwise, you can again log both request and response on server using other LoggingFilter (container filter).

提交回复
热议问题