案例很简单:用户单击注销,转到 LogoutFilter 并:
HttpServletRequest hreq = (HttpServletRequest) request;
hreq.getSession(false).invalidate();
HttpServletResponse httpResponse = (HttpServletResponse) response;
httpResponse.reset();
httpResponse.setHeader("Cache-Control", "no-cache");
httpResponse.setHeader("Pragma", "no-cache");
httpResponse.setHeader("Cache-Control", "no-store");
httpResponse.setHeader("Cache-Control", "must-revalidate");
httpResponse.setDateHeader("Expires", 0);
chain.doFilter(request, response);
并在页面上显示登录链接。问题很简单:会话重新创建,但用户主体已被缓存,因此没有显示登录弹出窗口并且应用程序使用缓存的主体,因为 request.getUserPrincipals() 返回非空对象。
问题很简单:有没有办法删除用户主体,所以浏览器在注销后要求再次登录?