/** * @ClassName: CorsConfig * @Description: 允许跨域请求 * @author: liwei * @date: 2019年2月27日 下午3:25:17 */ @Configuration @EnableWebMvc public class CorsConfig implements WebMvcConfigurer { @Override public void addCorsMappings(CorsRegistry registry) { //设置允许跨域的路径 registry.addMapping("/**") //设置允许跨域请求的域名 .allowedOrigins("*") //是否允许证书 不再默认开启 .allowCredentials(true) //设置允许的方法 .allowedMethods("*") //跨域允许时间 .maxAge(3600); } }
springboot 2.X 支持跨域
最新推荐文章于 2024-08-01 08:00:00 发布