android post传递数组类型数据给后台php

post方式只要改变你的键的数据类型,后台就会得到这个类型,然后就可以识别出这个数据的类型了。键改成这样就可以了,files[]

 OkGo.post(URLConstant.ADD_WORK)
                .tag(this)
                .headers("token", token)
                .headers("identity", "0")//0是学生1是老师 默认为0
                .params("id", homeWorkId)
                .params("memo", memo)
                .addUrlParams("files[]", files)
                .execute(new StringCallback() {
                    @Override
                    public void onStart(Request request) {
                        super.onStart(request);
                    }

                    @Override
                    public void onSuccess(Response response) {
                        try {
                            JSONObject object = new JSONObject(response.body());
                            Gson gson = new Gson();
                            BaseObjectBean bean = gson.fromJson(object.toString(), BaseObjectBean.class);
                            if (CommonlyConstant.VISITSUCCESS == bean.getCode()) {
                                mAddWorkCallBack.onSuccess(bean.getMsg());
                            } else {
                                mAddWorkCallBack.onCancel(bean.getMsg());
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            //                            mAddWorkCallBack.onCancel("提交异常,请稍后再试.");
                        }
                    }

                    @Override
                    public void onError(Response response) {
                        super.onError(response);
                        mAddWorkCallBack.onCancel("提交异常,请稍后再试.");
                    }
                });

 

你可能感兴趣的:(个人错误日常,android)