springboot解决跨域访问

/**
 * 跨域设置
 * @Version 1.0.0
 * @Description
 */
@Configuration
public class CorsConfig extends WebMvcConfigurationSupport {

    @Override
    protected void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowCredentials(true)
                .allowedMethods("GET","POST","DELETE","PUT")
                .maxAge(3600);
    }
}

猜你喜欢

转载自www.cnblogs.com/lazyli/p/12228931.html