HttpGet HttpPost HttpPut HttpDelete关于参数请求问题

String url = "http://www.login";//例子

HttpPost httpPost = new HttpPost(url);//将url放入post

//HttpPost或者HttpPut请求需要在请求里加参数,而HttpGet或者HttpDelete请求则可以直接拼接到url字符串后面

//向HttpPost中加入参数。

List values = new ArrayList();

values.add(new NameValuePair("name", "22"));

values.add(new NameValuePair("pwd", "22"));

httpPost.setEntity(new UrlEncodeFormEntity(values, HTTP.UTF_8));  //先转码

HttpGet方式:

url = url + "?name=22&pwd=22";


你可能感兴趣的:(HttpGet HttpPost HttpPut HttpDelete关于参数请求问题)