前提:我利用的是Xutils3框架。
RequestParams rp = new RequestParams(PsUtils.urlRegister);
rp.setAsJsonContent(true);
// rp.addHeader("Content-Type", "application/json");
JSONObject jo = new JSONObject();
try {
jo.put("phoneNum", user);
jo.put("password", password);
jo.put("verificationCode",code );
rp.setBodyContent(jo.toString());
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
利用 JSONObject 添加参数,
再用
RequestParams 的对象添加JSONObject 对象即可。