springboot 访问时 403 错误

1. 403是被服务器拒绝了,一般是spring security造成的,springsecurity会开启跨域认证,所以不关闭这个的话会访问api会出现403错误

 

2.解决

@Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            
            .and()
            .csrf()
            .disable()
....

在spring security 的控制类中加入以下代码即可,关闭跨域认证.

posted @ 2020-04-05 14:53  随意的马蒂洛克  阅读(10203)  评论(0编辑  收藏  举报