String url = "";
String bodyStr ="";
RestTemplate restTemplate = new RestTemplate();
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("Accept", MediaType.APPLICATION_JSON.toString());       <------重点
httpHeaders.add("Content-Type", MediaType.APPLICATION_JSON.toString()); <------重点
HttpEntity<String> httpEntity = new HttpEntity<>(bodyStr, httpHeaders);
ResponseEntity<String> responseEntity =
restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
String responseBody = String.valueOf(responseEntity.getBody());

相关文章:

  • 2021-09-07
  • 2022-01-17
  • 2021-08-13
  • 2021-04-16
  • 2021-10-29
  • 2022-12-23
  • 2021-06-01
  • 2022-03-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-22
  • 2022-12-23
  • 2021-05-18
  • 2021-09-04
  • 2021-04-20
相关资源
相似解决方案