Java HttpPost请求基于apache的httpclient
来源:互联网 发布:hao123解压软件 编辑:程序博客网 时间:2024/03/29 01:05
<span style="font-family: Arial, Helvetica, sans-serif;">/**</span>
* 发送 post请求访问本地应用并根据传递参数不同返回不同结果*/public static void post(String url, List<BasicNameValuePair> formparams) {// 创建默认的httpClient实例.CloseableHttpClient httpclient = HttpClients.createDefault();// 创建httppostHttpPost httppost = new HttpPost(url);// 创建参数队列UrlEncodedFormEntity uefEntity;try {uefEntity = new UrlEncodedFormEntity(formparams, "UTF-8");httppost.setEntity(uefEntity);System.out.println("executing request" + httppost.getURI());CloseableHttpResponse response = httpclient.execute(httppost);try {HttpEntity entity = response.getEntity();if (entity != null) {System.out.println("--------------------------------------");System.out.println("Response content: " + EntityUtils.toString(entity, "UTF-8"));System.out.println("--------------------------------------");}} finally {response.close();}} catch (ClientProtocolException e) {e.printStackTrace();} catch (UnsupportedEncodingException e1) {e1.printStackTrace();} catch (IOException e) {e.printStackTrace();} finally {// 关闭连接,释放资源try {httpclient.close();} catch (IOException e) {e.printStackTrace();}}}
0 0
- Java HttpPost请求基于apache的httpclient
- Java的HttpClient、HttpGet和HttpPost请求
- java的httppost请求
- HttpClient HttpPost请求
- java中用httpClient请求service,httpPost方法示例
- 关于HttpClient HttpGet和HttpPost 请求的运用
- Java用apache的HttpClient发送Post请求
- JAVA 调用HTTPPOST请求
- 【JavaWeb开发】用Apache的HttpClient4.5完成HttpPost请求
- android httpPost 的请求
- HTTPClient模块的HttpGet和HttpPost(处理http请求响应)
- 使用HttpClient发送HttpPost请求包含上传本地图片和远程图片的传输实现
- 设置Apache的HttpClient请求时间超时
- apache httpclient新版本的get/post请求
- httpClient httpPost
- java代码发送JSON格式的httpPOST请求
- java代码发送JSON格式的httpPOST请求
- java代码发送JSON格式的httpPOST请求
- get与post的区别
- 错误180无法将文件“obj\x86\Debug\WpfApplication3.exe”复制到“bin\Debug\WpfApplication3.exe”。文件“bin\Debug\WpfAp
- ViewPager自动轮播的几种方法
- 继续学乘法
- 关于 csdn 博客添加友情链接~~~~~
- Java HttpPost请求基于apache的httpclient
- Redis 的七个原则,以向大家阐明 Redis 的思想。
- HDU Problem 4883 TIANKENG’s restaurant (区间暴力)
- android中intent传递list或者对象的方法
- java毕向东听课笔记22(集合框架-List集合共性方法)
- sql入门学习2
- 堆栈的区别及增长方向
- 最大连续子序列和
- C# string 对象 0008