RestTemplate的postForEntity方法传递数组,将集合转换成json字符串

public Object xxxx(List<Xxxx> xxxx) {
HttpHeaders headers = new HttpHeaders();
HttpEntity<String> entity = new HttpEntity<>(JSON.toJSONString(xxxx), headers);
ResponseEntity<Object> response = restTemplate.postForEntity("url", entity, Object.class);
return response.getBody();
}
posted @ 2022-04-25 09:14  不要学我说话  阅读(1045)  评论(0编辑  收藏  举报