-
实现需求
在登录之后显示数据库中的三级分表 -
前后端总体架构
-
前后端联调过程
-
解决跨域问题
- 跨域问题的产生:前端和后端使用的地址或者端口不同产生跨域问题
- 为什么会有跨域:浏览器为了安全,规定只有域名,端口,协议全部相同,就叫做同源,才能直接访问资源,否则就叫做跨域。
- 配置代码
@Bean
public CorsWebFilter corsWebFilter(){
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration corsConfiguration = new CorsConfiguration();
//1、配置跨域
//允许所有请求来源允许跨域
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.setAllowCredentials(true);
source.registerCorsConfiguration("/**",corsConfiguration);
return new CorsWebFilter(source);
}