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.后续

先解决问题,后续再更新

原文地址:https://www.cnblogs.com/jnnleo/p/14120555.html