使用restTemplate时报下面的错误
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
解法方法
加上代码:
bean初始化时加上
HttpComponentsClientHttpRequestFactory factory =
new HttpComponentsClientHttpRequestFactory();
HttpClient httpClient =
HttpClientBuilder.create()
.setRedirectStrategy(new LaxRedirectStrategy())
.build();
factory.setHttpClient(httpClient);
restTemplate.setRequestFactory(factory);