public static String getJSONArrayByWeb(String methodName, JSONObject params) {
String returnValue = "";
JSONObject result = null;
HttpParams httpParams = new BasicHttpParams();
httpParams.setParameter("charset", "UTF-8");
HttpClient hc = new DefaultHttpClient(httpParams);
/*hc.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,60000);
hc.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,60000);*/
// hc.getParams().setParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE,5103813);
HttpPost hp = new HttpPost(Config.SERVER_IP + "/Home/"
+ methodName);
hp.setHeader("Content-Type","application/json");
try {
hp.setEntity(new StringEntity(params.toString(), "UTF-8"));
HttpResponse hr = hc.execute(hp);
if (hr.getStatusLine().getStatusCode() == 200) {
Log.d("httpresponse",hr.getEntity().getContentLength()+"----");
HttpEntity httpEntity=hr.getEntity();
returnValue = EntityUtils.toString(httpEntity, "UTF-8");//就这里返回不全
Log.d("httpresponse",returnValue+"********");
Log.d("httpresponse",returnValue.length()+"********");
// result=new JSONObject(returnValue);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (hc != null) {
hc.getConnectionManager().shutdown();
//hc=null;
}
return returnValue;
}
http://www.oschina.net/question/2491119_2138189
你需要确认返回的编码格式。可以先看看httpEntry中数据是否正确