Hutool工具包HttpRequest.post(url)请求设置,Hutool使用HttpRequest.post(url)请求
·
如下
JSONObject jsonObject = new JSONObject();
jsonObject.put("clientId", clientId);
jsonObject.put("secret", SecureUtil.md5(secret));
jsonObject.put("userId", userId);
Map<String, String > heads = new HashMap<>();
heads.put("Content-Type", "application/json;charset=UTF-8");
String result = HttpRequest.post(userRoleUrl)
.headerMap(heads, false)
.body(jsonObject.toJSONString()).timeout(30*1000).execute().body();
或
JSONObject json = new JSONObject();
json.put("code", config.getCode());
json.put("pass", config.getPass());
String result = HttpRequest.post(config.getUrlPersonal())
.header("Content-Type", "application/x-www-form-urlencoded").form(json).execute().body();
官方例子:https://hutool.cn/docs/#/http/Http%E8%AF%B7%E6%B1%82-HttpRequest
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)