Jersey:打印实际请求

Jersey: Print the actual request(Jersey:打印实际请求)

本文介绍了Jersey:打印实际请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何查看 Jersey 生成并发送到服务器的实际请求?我遇到了特定请求的问题,运行网络服务器的人要求查看完整的请求(带有标头等).

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 see the full request (with headers and the such).

推荐答案

如果你只是使用 Jersey Client API,LoggingFilter (客户端过滤器)应该可以帮助你:

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);

否则,您可以使用其他 LoggingFilter(容器过滤器).

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

这篇关于Jersey:打印实际请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Jersey:打印实际请求

基础教程推荐