android网络编程——HttpGet、HttpPost比较
2015-05-27 20:36
405 查看
在Android SDK中提供了Apache HttpClient(org.apache.http.*)模块。在这个模块中涉及到两个重要的类:HttpGet和HttpPost,他们有共性也有不同。
HttpGet和HttpPost创建方式相同:
1、创建HttpGet(或HttpPost)对象,将要请求的URL通过构造方法传入HttpGet(或HttpPost)对象中;2、使用DefaultHttpClient类的execute方法发送HTTP GET或HTTP POST 请求,并返回HttpResponse对象;
3、通过HttpResponse接口的getEntity方法返回响应信息。
HttpGet和HttpPost不同点,HttpPost在使用是需要传递参数
,使用List<NameValuePair>添加参数。
[java] view
plaincopyprint?
<span style="font-weight: normal;"> List<NameValuePair> postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("username", "test"));
postParameters.add(new BasicNameValuePair("password", "test1234"));</span>
/**
* @author 张兴业
* 邮箱:xy-zhang#163.com
* android开发进阶群:278401545
*
*/
相关文章推荐
- android网络编程——HttpGet、HttpPost比较
- android网络编程——HttpGet、HttpPost比较
- android网络编程——HttpGet、HttpPost比较
- android网络编程——http post 和 http get
- android网络编程http的get,post方式
- android--------HttpURLConnection的get,post和图片加载
- android 网络连接 HttpGet HttpPost方法
- HTTP请求方式之GET和POST比较
- HTTP POST GET详解 --讲得比较清楚
- HTTP 请求方式: GET和POST的比较
- Android 向服务器提交数据(GET-POST-AsyncHttpClient)
- Android-向服务器提交数据(GET-POST-AsyncHttpClient)
- Android使用HTTP GET、HTTP POST获取网络数据
- Android HTTP请求 POST、GET
- Android HttpClient GET或者POST请求基本使用方法
- 【HTTP】全面比较HTTP GET与POST方法
- Android HTTP Client: GET, POST, Download, Upload, Multipart Request
- Android 发送HTTP GET POST 请求以及通过 MultipartEntityBuilder 上传文件(二)
- Android HttpClient GET或者POST请求基本使用方法
- android中http的get,post方法代码