今天用看了一句代码:
HttpClient httpClient = new HttpClient();
// 创建GET方法的实例
GetMethod getMethod = new GetMethod(ConstConfig.URL_SZICITY_LOGIN + "aaa.do?id=" + ConstConfig.SZICITY_THIRD_ID + "&auth="
+ ConstConfig.SZICITY_THIRD_AUTH+"&mobile="+mobilename);
//这名:
getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
说明:
HttpMethodParams.RETRY_HANDLER是一个静态变量值:http.method.retry-handler
在参数中增加这句,是说让httpclient调用时/,如果Http出错,三次重试(DefaultHttpMethodRetryHandler这个类中已经默认设置为3)