HttpGet HttpPost HttpPut HttpDelete关于参数请求问题
2016-11-02 09:14
786 查看
String url = "http://www.login";//例子
HttpPost httpPost = new HttpPost(url);//将url放入post
//HttpPost或者HttpPut请求需要在请求里加参数,而HttpGet或者HttpDelete请求则可以直接拼接到url字符串后面
//向HttpPost中加入参数。
List<NameValuePair> values = new ArrayList<NameValuePair>();
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";
HttpPost httpPost = new HttpPost(url);//将url放入post
//HttpPost或者HttpPut请求需要在请求里加参数,而HttpGet或者HttpDelete请求则可以直接拼接到url字符串后面
//向HttpPost中加入参数。
List<NameValuePair> values = new ArrayList<NameValuePair>();
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";
相关文章推荐
- 关于 HTTP GET/POST 请求参数长度最大值的问题
- ajax参数传递之[HttpGet]/[HttpPost]/[HttpPut]/[HttpDelete]请求
- 关于 HTTP GET/POST 请求参数长度最大值的问题
- ajax参数传递之[HttpGet]/[HttpPost]/[HttpPut]/[HttpDelete]请求
- Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete
- Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete
- HttpPost,HttpGet,HttpPut,HttpDelete请求方式
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- Http请求访问方式 GET PUT POST DELETE
- Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete
- 关于mvc、webapi中get、post、put、delete的参数
- Http服务器的交互请求 GET,POST,PUT和DELETE
- Http四种请求方式:post ,get ,put,delete
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- ASIHTTPRequest实现对PUT,DELETE,POST,GET请求方式的处理
- 关于winfrom程序http post请求多参数问题
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete