休息模板接受标题

时间:2015-09-01 07:28:11

标签: resttemplate

我尝试将Accept标头设置为 application / json ,在服务调用期间,我可以看到“ DEBUG osweb.client.RestTemplate - 将请求接受标头设置为[text / plain, / ]“用日志写的。我的接受标题被覆盖了吗?如何限制?

代码段:

    RestTemplate template = new RestTemplate();
HttpHeaders requestHeaders = new HttpHeaders();
        requestHeaders.add(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON);
        requestHeaders.add(HttpHeaders.ACCEPT, APPLICATION_JSON);
String url = "http://*******"
HttpEntity<String> request = new HttpEntity<String>(requestBody, requestHeaders);
HttpEntity<String> response = template.exchange(url, HttpMethod.POST, request, String.class);

日志:

{Content-Type=[application/json], Accept=[application/json]}

13:08:06.091 [main] DEBUG o.s.web.client.RestTemplate - Created POST request for "http://********"
13:08:06.097 [main] DEBUG o.s.web.client.RestTemplate - Setting request Accept header to [text/plain, */*]

0 个答案:

没有答案