玩转SpringBoot 跨域问题的 3 种方案

1. 第一种import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.config.annotation.CorsRegistry;import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;/** * @authorMcally * @time* @des跨越解决方式 */@Configurationpublic class CorsConfig implements WebMvcConfigurer {@Overridepublic void addCorsMAppings(CorsRegistry registry) {registry.addMapping("/**").allowedOrigins("*").allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS").allowCredentials(true).maxAge(3600).allowedHeaders("*");}}

【玩转SpringBoot 跨域问题的 3 种方案】


    推荐阅读