我在一个web应用程序中使用Apache Shiro。登录和验证检查工作得很好,但我有一个问题,以实现注销/重新登录机制:Shiro:Session已经失效
private void logout(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
log.debug("do logout");
Subject subject = SecurityUtils.getSubject();
subject.logout();
resp.sendRedirect("end.html");
}
但注销并重新登录,我得到以下后:注销是在servlet完成错误:
org.apache.shiro.session.InvalidSessionException: java.lang.IllegalStateException:
getAttribute: Session already invalidated
at org.apache.shiro.web.session.HttpServletSession.removeAttribute(HttpServletSession.java:167)
at org.apache.shiro.session.ProxiedSession.removeAttribute(ProxiedSession.java:135)
at org.apache.shiro.subject.support.DelegatingSubject.clearRunAsIdentities(DelegatingSubject.java:424)
at org.apache.shiro.subject.support.DelegatingSubject.login(DelegatingSubject.java:246)
登录按以下方式进行(在UI组件的方法,我用ZK作为UI框架):
private void tryLogin(UsernamePasswordToken token) {
Subject subject = SecurityUtils.getSubject();
try {
subject.login(token);
...
我不明白的例外,因为注销FR om shiro使会话无效,重新登录应该访问新的会话。
感谢您的帮助
嗨,我使用的版本四郎'1.2.4',仍然得到同样的问题'的getAttribute:会话已经invalidated'注销后重新登录。任何帮助? – Newbie 2016-01-29 19:11:53