HttpClient基本用法
来源:互联网 发布:凤凰刷机软件 编辑:程序博客网 时间:2024/06/06 08:58
Get方式:
String url="http://localhost:8080/HttpClientDemo/test";HttpGet httpRequest=new HttpGet(url);HttpClient httpClient=new DefaultHttpClient();HttpResponse response=httpClient.execute(httpRequest);if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){String result=EntityUtils.toString(response.getEntity());System.out.println(result);}
Post方式:
String url="http://localhost:8080/HttpClientDemo/test";HttpPost request=new HttpPost(url);List<NameValuePair> params=new ArrayList<NameValuePair>();params.add(new BasicNameValuePair("name", "testname"));HttpEntity httpEntity=new UrlEncodedFormEntity(params,"utf-8");request.setEntity(httpEntity);HttpClient httpClient=new DefaultHttpClient();HttpResponse response=httpClient.execute(request);if(response.getStatusLine().getStatusCode()==HttpStatus.SC_OK){String result=EntityUtils.toString(response.getEntity());System.out.println(result);}
- HttpClient基本用法
- httpclient基本用法
- HttpClient基本用法
- httpclient基本用法讲解
- android httpclient基本用法
- HttpClient基本用法
- JAVA HttpClient 基本用法
- HttpClient的基本用法
- HttpConnect与HttpClient基本用法
- HttpClient基本用法以及HTTP站点认证实例
- HttpClient用法
- httpclient用法
- HttpClient 用法
- HttpClient的基本使用
- Android HttpClient基本使用方法
- Android HttpClient基本使用方法
- Android HttpClient基本使用方法
- HttpClient的基本操作
- Ubuntu更新命令
- 新手学cocos2D小笔记-NSMutableArray的使用
- jre精简详细教程(附精简工具)
- Win32ASM学习[11]:逻辑运算
- 我的开发工具与环境( g++, Eclipse , qt-4.4.3 ) 转
- HttpClient基本用法
- 注册页对协议的判定(JS)
- JAVA基础之理解JNI原理
- 动态规划法解决装载问题
- 软件测试风险分析
- LPC2103学习之外部中断
- Android生成缩略图-使用Android 2.2新特性完成
- HttpClient 3.1 文件上传
- 资治通鉴,卷一百二十六,刘宋文帝刘义隆最后时光