工作随笔:RestTmplate的接口请求
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", "application/json");
HttpEntity<String> requestEntity = new HttpEntity<>(null, headers);
ResponseEntity<String> resEntity = restTemplate
.exchange(url, HttpMethod.GET, requestEntity, String.class);
String body = resEntity.getBody();
JSONObject object = JSON.parseObject(body);
JSONObject jsonObject = object.getJSONObject("data");
Object content = jsonObject.get("content");
List<MessageDto> list = JSON.parseArray(JSON.toJSONString(content), MessageDto.class);
每天一小步,收获一大步