请求代码:
public static String get(String url) throws Exception {
log.info("HTTP GET:" + url);
HttpGet req = new HttpGet(url);
req.setHeader("Content-type", "application/json");
req.setHeader("charset", "UTF-8");
HttpResponse res = HttpClients.createDefault().execute(req);
String result = "";
if (200 == res.getStatusLine().getStatusCode()) {
result = EntityUtils.toString(res.getEntity());
}
return result;
}
res.getStatusLine().getStatusCode()是 503
但是用浏览器直接访问地址是可以返回值的,请教哪里写错了