美文网首页
springboot跨域问题

springboot跨域问题

作者: Easy的幸福 | 来源:发表于2018-01-15 17:29 被阅读0次

Application 类配置 如下:

@Configuration

publicclassCorsConfig {

    privateCorsConfiguration buildConfig() {

        CorsConfiguration corsConfiguration = newCorsConfiguration();

        corsConfiguration.addAllowedOrigin("*");

        corsConfiguration.addAllowedHeader("*");

        corsConfiguration.addAllowedMethod("*");

        returncorsConfiguration;

    }

    @Bean

    publicCorsFilter corsFilter() {

        UrlBasedCorsConfigurationSource source = newUrlBasedCorsConfigurationSource();

        source.registerCorsConfiguration("/**", buildConfig());

        returnnewCorsFilter(source);

    }

}

相关文章

网友评论

      本文标题:springboot跨域问题

      本文链接:https://www.haomeiwen.com/subject/mxydoxtx.html