whyclxw
2024-11-29 6eb5d9fa80de3f0820db92b5520aff43df010ff7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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);
    }
}