Call to j_spring_security_logout not working

前端 未结 6 1263
滥情空心
滥情空心 2020-12-16 11:52

I\'m trying to setup the logut of my application with j_spring_security_logout but for some reason it\'s not working, I keep getting a 404 error.

I\'m calling the fu

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 12:21

    With spring security 4 Logout has to be done through form button. CSRF token has to be submitted along. j_spring_security_logout does not work any longer. After spending one day i got following to be working.
    Step 1: In your JSP page

    
    

    Step 2

    
    
    
    
    

    Step 3 In your login controller

    //Logout mapping
    @RequestMapping("/logout")
    public String showLoggedout(){
        return "logout";
    }
    

    Step 4 You must have one logout.jsp

    Important to see that it will land onto login page after logout.

    
    

    So this login page must be there with corresponding mappping to login.jsp or whatever to map in your controller.

提交回复
热议问题