public static String HttpClientUtils(String param) throws Exception{
String param2= "1";
String param3= "2";
String appKey = "";
String sign = "";
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);//post带参接口
JSONObject json = new JSONObject();//json格式的参数
Map<String,Object> map = new HashMap<>();
map.put("param",param);
map.put("param1",param1);
map.put("param2",param2);
json.put("appKey",appKey);
json.put("sign",sign);
json.put("content",map);
try{
httpPost.addHeader("Content-type", "application/json; charset=utf-8");
httpPost.setHeader("Accept", "application/json");
httpPost.setEnt
HttpClient实现java调用外部接口
最新推荐文章于 2024-07-17 16:07:45 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)