NameValuePair是简单名称值对节点类型。多用于Java像url发送Post请求。在发送post请求时用该list来存放参数。
例如:
String url="访问网址";
HttpPost httppost=new HttpPost(url); //建立HttpPost对象
//建立一个NameValuePair数组,用于存储传送的数据
List<NameValuePair> params=new ArrayList<NameValuePair>();
//添加参数
params.add(new BasicNameValuePair("键","值"));
//设置编码
httppost.setEntity(new UrlEncodedFormEntity(params,Charsets.UTF_8));
//发送Post,并返回一个HttpResponse对象
HttpResponse response=new DefaultHttpClient().execute(httppost);
NameValuePair是简单名称值对节点类型
最新推荐文章于 2021-06-06 19:23:08 发布