import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
JSONObject jsonObject = JSONUtil.createObj();
jsonObject.put("shift", "D");
jsonObject.put("model", dataMap.get("MODEL"));
jsonObject.put("stage", dataMap.get("STAGE_GROUP"));
jsonObject.put("reflow", "Y");
jsonObject.put("startTime", startTime);
private List<Map<String, String>> exchange(JSONObject jsonObject, Map<String, String> requestMap) {
HttpResponse execute = HttpRequest.post(url)
//设置请求头(可任意加)
.header("NginxModel", requestMap.get("MODEL"))
.header("NginxStage", requestMap.get("STAGE_GROUP"))
.header("NginxProcess", requestMap.get("FATP"))
.header("sign", "e74167063074b180b6dafa567b2095a8f7996327")
//请求参数
.body(jsonObject.toString())
.execute();
String body1 = execute.body();
com.alibaba.fastjson2.JSONObject jsonObject1 = com.alibaba.fastjson2.JSONObject.parseObject(body1);
List<Map<String, String>> dataList = (List<Map<String, String>>)jsonObject1.get("data");
}
说实话 我都是使用restTemplate 不过里面有其他工具还是比较好用的 喜欢的可以研究下
ResponseEntity<Map> forEntity1 = restTemplate.postForEntity(sendUrl, jsonObject, Map.class);