码迷,mamicode.com
首页 > Web开发 > 详细

xUtils怎么post请求上传json数据

时间:2017-11-18 18:38:39      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:result   pex   json   tsm   roi   com   ons   request   ica   

        InfoSmallCodeBinding smallCode = new InfoSmallCodeBinding();
        smallCode.setSmallCode("测试");
        smallCode.setMiddleBoxCode("测试");
        smallCode.setProductCode("0001");
        Gson gson3 = new Gson();

        String url = AppConfig.ApiUrl+"?action=smallcodebindingadd";
        HttpUtils httpUtils = new HttpUtils();
        //Log.d("Http2635", "test: "+gson3.toJson(smallCode));
        RequestParams params = new RequestParams();
        params.setBodyEntity(new StringEntity(gson3.toJson(smallCode),"UTF-8"));
        params.setContentType("application/json");
        httpUtils.send(com.lidroid.xutils.http.client.HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
                    @Override
                    public void onSuccess(ResponseInfo<String> responseInfo) {
                        Log.d("Http2635", "onSuccess: "+responseInfo.result.toString());
                    }

                    @Override
                    public void onFailure(HttpException e, String s) {
                        Log.d("Http2635", "onFailure: "+e.toString());
                    }
                }
        );

 

xUtils怎么post请求上传json数据

标签:result   pex   json   tsm   roi   com   ons   request   ica   

原文地址:http://www.cnblogs.com/linfenghp/p/7857402.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!