android网络编程——HttpGet、HttpPost比较
来源:互联网 发布:win10如何优化内存 编辑:程序博客网 时间:2024/05/29 02:16
在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>添加参数。
List<NameValuePair> postParameters = new ArrayList<NameValuePair>(); postParameters.add(new BasicNameValuePair("username", "test")); postParameters.add(new BasicNameValuePair("password", "test1234"));
/**
* @author 张兴业
* 邮箱:xy-zhang#163.com
* android开发进阶群:278401545
*
*/
List<NameValuePair> postParameters = new ArrayList<NameValuePair>(); postParameters.add(new BasicNameValuePair("username", "test")); postParameters.add(new BasicNameValuePair("password", "test1234"));
* @author 张兴业
* 邮箱:xy-zhang#163.com
* android开发进阶群:278401545
*
*/
- android网络编程——HttpGet、HttpPost比较
- android网络编程——HttpGet、HttpPost比较
- android网络编程——HttpGet、HttpPost比较
- Android网络编程之HttpClient&HttpGet&HttpPost
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- android 网络编程 HttpGet类和HttpPost类使用详解
- win7下IIS7关键配置图解
- Introduction to Node.js(2)
- Concepts and terminology fundamental to Camel
- 14岁初中生—— 踏踏实实的人生也最美
- smartctl工具检测磁盘
- android网络编程——HttpGet、HttpPost比较
- android手机root后的安全问题 (二)
- 单身快乐(致一个人的情人节)
- Themida/WinLicense IAT 处理流程分析
- Linux内核态下的文件操作
- LINUX下安装jdk过程及其环境变量配置
- 修复linux grub引导程序
- 想念那一池莲花
- 一篇关于职业选择的好文章