一.
String str = HttpClientUtil.doGet(path, null, "utf-8");
Map mapUser = JSON.parseObject(str);
public class HttpClientUtil {
public static String doGet(String path, Map<String, Object> params, String charset) throws Exception {
HttpClient httpClient = null;
HttpGet httpPost = null;
String result = null;
try {
httpClient = new SSLClient();
httpPost = new HttpGet(path);
HttpResponse response = httpClient.execute(httpPost);
if (response != null) {
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
result = EntityUtils.toString(resEntity, charset);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return result;
}
}
二、
String returnValue = send(url, null);
Map mapuser = JSON.parseObject(returnValue);
public String send(String url, Map<String, Object> param){
HttpGet httpGet = new HttpGet(url, null, param);
httpGet.execute();
return httpGet.getResult();
}