Hutool工具类Http请求整理

时间:2025-02-16 08:13:08
// 1. 请求url String url = ""; // 2. 请求参数 Map<String, Object> param = new HashMap<>(); param.put("param", "param"); // 3. 开始执行 HttpResponse resp = HttpRequest.post(url) .addHeaders(new HashMap<>()).body(JSONObject.toJSONString(param)).execute(); // 4. 处理返回参数 // body String body = resp.body(); // status int status = resp.getStatus(); // headers Map<String, List<String>> headers = resp.headers();