栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

spring

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

spring

我想知道你是

you are following the correct path
因为用户会话无效

    usersSessions.forEach((session) -> {     sessionRegistry.getSessionInformation(session.getId()).expireNow();    });

注意事项

SessionInformation.expireNow()

并不意味着要从

redis
数据库中删除条目,它只是将您已提到的过期属性附加到会话。

但是,这如何使用户会话无效?

这是ConcurrentSessionFilter发挥作用的地方,

.doFilter()
方法实现了
automatically logging out

这是 ConcurrentSessionFilter* 的代码段 *

public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)        throws IOException, ServletException {    HttpServletRequest request = (HttpServletRequest) req;    HttpServletResponse response = (HttpServletResponse) res;    HttpSession session = request.getSession(false);    if (session != null) {        SessionInformation info = sessionRegistry.getSessionInformation(session     .getId());        if (info != null) { if (info.isExpired()) {     // Expired - abort processing     doLogout(request, response);     String targetUrl = determineExpiredUrl(request, info);     if (targetUrl != null) {         redirectStrategy.sendRedirect(request, response, targetUrl);         return;     }     else {         response.getWriter().print(      "This session has been expired (possibly due to multiple concurrent "   + "logins being attempted as the same user).");         response.flushBuffer();     }     return; } else {     // Non-expired - update last request date/time     sessionRegistry.refreshLastRequest(info.getSessionId()); }        }    }    chain.doFilter(request, response);}

为此加油!



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/367178.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号