okhttp 3.0 多参数传递
来源:互联网 发布:灵魂摆渡3风华绝代知乎 编辑:程序博客网 时间:2024/05/22 02:11
//post 请求 public Call postAsynHttp(String url, Map<String, String> params) { FormBody.Builder builder = new FormBody.Builder(); Param[] paramsArr = map2Params(params); for (Param param : paramsArr){ builder.add(param.key,param.value).build(); } RequestBody body = builder.build(); Request request = new Request.Builder().url(url).post(body).build(); Call call = mOkHttpClient.newCall(request); return call; }
/** * post请求参数类 */ public static class Param { String key;//请求的参数 String value;//参数的值 public Param(String key, String value) { this.key = key; this.value = value; } } private Param[] map2Params(Map<String, String> params) { if (params == null) return new Param[0]; int size = params.size(); Param[] res = new Param[size]; Set<Map.Entry<String, String>> entries = params.entrySet(); int i = 0; for (Map.Entry<String, String> entry : entries) { res[i++] = new Param(entry.getKey(), entry.getValue()); } return res; }
//调用
final String phone = et_usertel.getText().toString(); String regCode = et_code.getText().toString(); Map<String, String> param = new HashMap<>(); param.put("regCode", regCode); param.put("phone",phone); Call mcall = okHttpUtils.postAsynHttp(Constant.BASE_URL + Constant.REGISTER_URL, param);
0 0
- okhttp 3.0 多参数传递
- android OKhttp 参数 传递数组类型
- 多参数传递问题
- CreateThread多参数传递
- jfreechart 多参数传递
- mybatis多参数传递
- MyBatis多参数传递
- 【Mybatis】多参数传递
- MyBatis多参数传递
- Mybatis多参数传递
- okhttp详解(参数)
- AndroidStudio okhttp get 参数
- OkHttp参数拼接
- OKHTTP封装公共参数
- Mybatis 3.0 参数的传递
- showModalDialog传递多个参数
- 多个参数的传递
- 使用params传递多参数
- JavaScript对象复制、扩展(改变原对象的引用,避免原对象被动态的改变值);
- 关于SAP系统变量
- 自适应布局,完美解决左右两边固定大小,中间内容适应大小。
- react native:andorid给iOS的navi多出20像素左右
- Jenkins的使用---项目构建,邮件通知
- okhttp 3.0 多参数传递
- MyBatis缓存配置
- 国军标-Gjb软件设计说明书模板
- android 面试题
- 面向对象整体GIS数据模型的设计与实现
- Python学习-格式化输出
- [Leetcode]61. Rotate List
- HBase shell scan命令中filter的使用
- 服务治理与Dubbo架构