后台:完整的跨域代码
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedHeaders("*")
.allowedMethods("*")
.allowedOrigins("*")
.allowCredentials(true);
}
}
前台:
vue:在main.js import的下面加上这个代码
axios.defaults.withCredentials = true
jquey:在使用ajax的时候一定要设置
xhrFields:{withCredentials:true}
参考资料:https://blog.csdn.net/qq_38082304/article/details/79914994