NameValuePair
2016-10-11 18:03
316 查看
定义了一个list,该list的数据类型是NameValuePair(简单名称值对节点类型),这个代码多处用于Java像url发送Post请求。在发送post请求时用该list来存放参数。
发送请求的大致过程如下:
String url="http://www.baidu.com";
HttpPost httppost=new HttpPost(url); //建立HttpPost对象
List<NameValuePair> params=new ArrayList<NameValuePair>();
//建立一个NameValuePair数组,用于存储欲传送的参数
params.add(new BasicNameValuePair("pwd","2544"));
//添加参数
httppost.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
//设置编码
HttpResponse response=new DefaultHttpClient().execute(httppost);
//发送Post,并返回一个HttpResponse对象
发送请求的大致过程如下:
String url="http://www.baidu.com";
HttpPost httppost=new HttpPost(url); //建立HttpPost对象
List<NameValuePair> params=new ArrayList<NameValuePair>();
//建立一个NameValuePair数组,用于存储欲传送的参数
params.add(new BasicNameValuePair("pwd","2544"));
//添加参数
httppost.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
//设置编码
HttpResponse response=new DefaultHttpClient().execute(httppost);
//发送Post,并返回一个HttpResponse对象
相关文章推荐
- NameValuePair问题
- HttpClient+List<NameValuePair>发送和接收参数——基于struts2或者ssh等框架
- 接口测试入门(3)--使用httpClient进行登录用例操作/set-cookies验证/ List<NameValuePair>设置post参数/json解析
- The type org.apache.http.NameValuePair cannot be resolved
- 10、BasicNameValuePair
- List<NameValuePair> params = new ArrayList<NameValuePair>();
- NameValuePair是简单名称值对节点类型
- HttpClient---NameValuePair参数问题
- android studio 导入 org.apache.http.message.BasicNameValuePair 报错的解决
- 我的Android进阶之旅------>android如何将List<NameValuePair>请求参数列表转换为json格式
- Passing Name Value Pair to the Biztalk Orchestration
- 修改Activity为AppCompatActivity ,用6.0编译。报错The type org.apache.http.NameValuePair cannot be resolved.
- JSON--就是名值对 name/value pair
- API23org.apache.http.NameValuePair 需要自己写入gradle的关联
- NameValuePair在API22过时问题
- HttpClient--BasicNameValuePair
- NameValuePair is deprecated in API 22
- post的NameValuePair[] nvp调用方法输出System.out........
- NameValuePair的用法
- httpclient namevaluepair 模拟form表单