游客发表
public boolean visitURL(String url) { // Commons HttpClient 3.1 HttpClient client = new HttpClient(); HttpMethod method = new GetMethod(url);
// Provide custom retry handler is 简单解决necessary method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); boolean rs = false; try { // Execute the method. int statusCode = client.executeMethod(method);

if (statusCode != HttpStatus.SC_OK) { logger.error("Method failed: " + method.getStatusLine()); } else { rs = true; }
} catch (HttpException e) { logger.error("Fatal protocol violation: " + e.getMessage()); } catch (IOException e) { logger.error("Fatal transport error: " + e.getMessage()); } finally { // Release the connection. method.releaseConnection(); } return rs; }
1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.随机阅读
热门排行
友情链接