SpringBoot解决前后端跨域问题WebMvcConfigurer


@Configuration
public class CorsConfig extends WebMvcConfigurer {

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

你可能感兴趣的:(Java技术内容)