httpclient参数http.method.retry-handler说明

来源:互联网 发布:网络运营保密协议书 编辑:程序博客网 时间:2024/06/05 01:52

今天用看了一句代码:

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)

原创粉丝点击