我试图使用android httpclient(loopj)发布一些数据。我在其正文中添加了一些json数据并设置了请求标头。但它显示AsyncHttpClient:传递的contentType将被忽略,因为HttpEntity设置了内容类型。有谁知道如何解决这个问题?
public static void post(Activity context,String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
try {
JSONObject jsonParams = new JSONObject();
JSONObject innerObject = new JSONObject();
innerObject.put("Name", "@MODE");
innerObject.put("ParamType", "8");
innerObject.put("Value", "0");
JSONArray ar = new JSONArray();
ar.put(innerObject);
try {
jsonParams.put("ProcName", "Core.MENUS_SPR");
jsonParams.put("dbparams", ar);
Log.i("jsonParams.toString()",""+jsonParams.toString());
StringEntity se = null;
try {
se = new StringEntity(jsonParams.toString());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return;
}
client.post(context, (url), se, "application/json", responseHandler);
} catch (JSONException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}