volley框架的使用post带参数遇到的问题

来源:互联网 发布:投资经理 知乎 编辑:程序博客网 时间:2024/04/29 21:33

关于volley用法的详细介绍参考

http://www.cnblogs.com/caobotao/p/5071658.html

http://blog.csdn.net/guolin_blog/article/details/17482095

以下是以上两篇文章及在网上找到的关于volley带参数的post请求写法:

  1. StringRequest stringRequest = new StringRequest(Method.POST, url,  listener, errorListener) {  
  2.     @Override  
  3.     protected Map<String, String> getParams() throws AuthFailureError {  
  4.         Map<String, String> map = new HashMap<String, String>();  
  5.         map.put("params1""value1");  
  6.         map.put("params2""value2");  
  7.         return map;  
  8.     }  
  9. };  

本来post方式带参数只要重写getParams方法,然后构造一个map,将键值对设置进去就好了,不过在实际使用过程中发现这种方法无法请求成功,找了好久也找不到原因,就源码来说这样写应该是对的呀。有人知道可能是什么原因吗?

最后 没办法直接把参数带url里面去就请求成功了。

0 0
原创粉丝点击