connect访问307解决办法

1.前言

项目上使用connect直接请求url返回307错误

2.改为client方式访问

HttpClientBuilder custom = HttpClients.custom();
custom.setUserAgent("Mozilla/5.0(Windows;U;Windows NT 5.1;en-US;rv:0.9.4)");
httpClient = custom.build();
HttpGet httpGet = new HttpGet(validateURL + "?ticket=" + ticket);
HttpResponse resp = httpClient.execute(httpGet);
if (resp.getStatusLine().getStatusCode() == 200) {
HttpEntity entity = resp.getEntity();
result = EntityUtils.toString(entity);
}

3.后续

先解决问题,后续再更新

posted @ 2020-12-11 15:22  jnnleo  阅读(617)  评论(0编辑  收藏  举报