基于CSS3的3D立方体旋转动画

SpringBoot+SpringSecurity注销时报错404的两种解决方法

SpringBoot+SpringSecurity注销时报错404的两种解决方法

security的404问题

解决方案

方法一: 关闭csrf保护

在SpringSecurity配置内中,关闭csrf保护

   ...
   @Override
    protected void configure(HttpSecurity http) throws Exception {
        //关闭跨域访问,解决注销404问题
        http.csrf().disable();

    }

方法二:以post方式提交“注销请求”

SpringSecurity的注销配置

//注销  
http.logout().logoutUrl("/toLogout").logoutSuccessUrl("/toLogin").invalidateHttpSession(true);

所以,这里将/toLogout请求改为用表单以post方式提交。在此方法下,不用关闭SpringSecurity的csrf保护

<form th:action="@{/toLogout}" method="post">
	<input type="submit" value="注销"/>
</form>
posted @ 2021-03-07 19:55  只会写error  阅读(1162)  评论(0)    收藏  举报