package com.whyc.config; import org.springframework.http.client.SimpleClientHttpRequestFactory; import java.io.IOException; import java.net.HttpURLConnection; public class NoRedirectClientHttpRequestFactory extends SimpleClientHttpRequestFactory { @Override protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException { // TODO Auto-generated method stub super.prepareConnection(connection, httpMethod); // 禁止自动重定向 connection.setFollowRedirects(false); } }