解决afinal服务器端接收参数为乱码问题

来源:互联网 发布:印尼网络怎么样 编辑:程序博客网 时间:2024/06/09 10:52
private void saveProject(JSONArray array, String url) throws JSONException, UnsupportedEncodingException {        String userid = getGson().fromJson(sp.getString("username", ""), String.class);        JSONObject object = new JSONObject();        object.put("item", array);        object.put("userid",userid);        object.put("areaID", areaID);        object.put("bz", beizhu.getText().toString());        StringEntity entity = new StringEntity(object.toString(), "utf-8");        getFinalHttp().post(                url,                entity,                "application/json; charset=utf-8",                new AjaxCallBack<Object>() {                    @Override                    public void onSuccess(Object o) {                        super.onSuccess(o);                        if (o.toString().equals("true")){                            Intent intent = new Intent(Constants.BROADCAST);                            mContext.sendBroadcast(intent);                          finish();                        }                    }                    @Override                    public void onFailure(Throwable t, int errorNo, String strMsg) {                        super.onFailure(t, errorNo, strMsg);                    }                }        );    }
此方法为调用服务器端的借口, 保存一个List集合,三个String参数,解决服务器端接收到的参数为乱码的根本是
StringEntity entity = new StringEntity(object.toString(), "utf-8");


0 0