工程架构: SpringBoot 2.2.1.RELEASE
通过RestTemplate 发起Http请求,并接收JSON格式的返回值和XML返回值;
GET请求带参传递(返回JSON格式):
通过{}为URL 注入参数,返回值用String接收在进行JSON转对象处理
public XiDaoHttpResult getXiDaoData() {
RestTemplate restTemplate = new RestTemplate();
String url = "http://xxxxx:xxxx?end_date_time={end_date_time}&start_date_time={start_date_time}";
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType.parseMediaType("application/json; charset=GBK");
headers.setContentType(type);
Mapparam = new HashMap<>();
// 设置开始时间和结束时间 开始时间为当天的0点,结束时间为当前时间
String startTime = DateUtil.DateFormatting("yyyy-MM-dd HH:mm:ss", DateUtil.initDateByDay());
String endTime = DateUtil.DateFormatting("yyyy-MM-dd HH:mm:ss", new Date());
par