保 洁 阿 姨

拥有60+年的前端设计经验

60+Years of front-end design experience

luzhou·sichuan

www.usuuu.com

Web网页设计:70888820

4个视频

Video list

Spring Boot跨域最佳解决方案

IP属地:四川省 / 发布于:4个月前 / 浏览:380

自己一直在用

WebMvcConfig

/**
  * 跨域配置
  */
@Bean
public CorsFilter corsFilter() {
    // 1.创建 CORS 配置对象
    CorsConfiguration config = new CorsConfiguration();
    // 支持域
    config.addAllowedOrigin("*");
    // 是否发送 Cookie
    config.setAllowCredentials(true);
    // 支持请求方式
    config.addAllowedMethod("*");
    // 允许的原始请求头部信息
    config.addAllowedHeader("*");
    // 暴露的头部信息
    config.addExposedHeader("*");
    // 2.添加地址映射
    UrlBasedCorsConfigurationSource corsConfigurationSource = new UrlBasedCorsConfigurationSource();
    corsConfigurationSource.registerCorsConfiguration("/**", config);
    // 3.返回 CorsFilter 对象
    return new CorsFilter(corsConfigurationSource);
}
给Ta打赏
共0人打赏

打赏的土豪们

Rewarded users

暂无打赏

© 未经允许禁止转载
回复
暂无数据

暂无数据

Vexip UI

Ui components

VexipUI提供了一系列开箱即用的组件,并使用全新的Vue3.0组合式Api编写,一款值得关注的Vue3UI组件库

Vexip UI

用户签到

User Sign

签到奖励积分

站点公告

Announcement

(友情链接)2023-3-21清除单项链接
Web网页设计交流群:70888820
QQ号为523179414的狗,谢绝访问

版权申明

本站原创内容版权遵循 CC-BY-NC-SA 协议规定,转载请注明出处.本站部分资源收集于网络,只做学习和交流使用,版权归原作者所有.