Spring Security - cannot logout [closed]

瘦欲@ 提交于 2019-12-05 16:18:17

It's problem no in JSP redirects but in settings.

Try this:

Add to web.xml

<listener> 
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class> 
</listener>

The standard for Spring security log outs is as follows:

SecurityContextHolder.clearContext();

EDIT

If you are using jsp redirects, what needs to happen is you need an empty jsp that does the following things:

1) Invalidates the session
2) Redirects to a landing page

When I say empty I mean the only content inside of it is a scriptlet that does the two pieces above. So the process will look as follows:

1) User presses log out
2) A redirect to the dummy page as described above occurs
3) Dummy page executes its code
4) User is now logged out of the system.

JSP CODE

<html>  
    <%session.invalidate()%>    
    //redirect logic
</html>  
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!