直接上代码 Map<String, Object> param = new HashMap<>(); param.put("参数1", "value1"); param.put("参数2", "value2"); param.put("参数3", "value3"); List<NameValuePair> pairList = new ArrayList<>(); for(Map.Entry<String, Object> entry:param.entrySet()){ pairList.add(new BasicNameValuePair(entry.getKey(),entry.getValue().toString())); } HttpPost postMethod = new HttpPost(url);//传入URL地址 //此处可以对postmethod进行配置 postMethod.setEntity(new UrlEncodedFormEntity(pairList)); HttpResponse response = httpClient.execute(postMethod);//获取响应
Post请求使用params传参
最新推荐文章于 2024-07-24 16:49:00 发布