记录下,备查。
/** * 获取post请求响应 * @param url * @param params * @return */ public static String urlPostMethod(String url,String params) { HttpClient httpClient = new HttpClient(); PostMethod method = new PostMethod(url); try { if(params != null && !params.trim().equals("")) { RequestEntity requestEntity = new StringRequestEntity(params,"text/xml","UTF-8"); method.setRequestEntity(requestEntity); } method.releaseConnection(); httpClient.executeMethod(method); String responses= method.getResponseBodyAsString(); return responses; } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
调用:
String getURL = "http://localhost:8080/pr/rest/aggregation/getAll"; String params = "{everyPageNum:22,currentPage:1}"; String s = DataAggregationUtil.urlPostMethod(getURL, params); System.out.println(s);
相关推荐
本人自己总结的httpClient PostMethod 上传文件完整实例 以及 使用java PostMethod 和GetMethod 发送请求实例 及乱码处理
利用c# httpclient ,post json数据到web api
通过httpclient获取到JSON数据,展示到ListView通过httpclient获取到JSON数据,展示到ListView
Android客户端向服务器端请求数据的两种主要方式:HTTPURLConnection、HTTPClient;内含客户端与服务器端Demo(带有详细注释),原生方式解析json数据,希望大家多多批评指教!!
使用HttpURLConnection或HttpClient方式传json值到spring中
Android例子源码httpclient获取到JSON数据并展示到ListView
通过httpclient获取到JSON数据展示到ListView.zip
Android高级应用源码-通过httpclient获取到JSON数据,展示到ListView.zip
该Demo主要介绍使用HttpClient获取网络数据,然后经过JSON后显示出来。另外本文章用到了常用的异步加载技术,AsyncTask类。
提交路径传递json参数(httpClient请求) 有代码和视频介绍;
HttpClient发送json、普通参数类型的Post请求(csdn)————程序
使用Arduino程式擷取Json檔案內的屬性資料,以至於後續物聯網開發。
NULL 博文链接:https://cxl2012.iteye.com/blog/2210521
NULL 博文链接:https://zhcheng.iteye.com/blog/1292350
httpclient模拟post请求json封装表单数据的实现方法 httpclient模拟post请求json封装表单数据的实现方法
利用HttpClient获取数据并用Gson解析Json数据,内容比较简单,适合新手
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,...
NULL 博文链接:https://javasam.iteye.com/blog/2117845
httpClient获取json格式的数据,并将数据赋值与自动化测试平台