如何获取Session对象中的对象

先调用request的getSession()方法获取一个HttpSession的对象,然后将这个对象进行强制类型转换成原本封装的对象,这样就能获取Session对象中的对象了

1、调用request的getSession()方法

HttpSession session = request.getSession();

2、强制类型转换

User user = (User) session.getAttribute("session_user");

Session注销后,浏览器后退仍显示Session信息的解决方案:
https://www.cnblogs.com/windowsxpxp/p/12190343.html

posted @ 2020-01-14 08:58  Windows_XP  阅读(3726)  评论(0编辑  收藏  举报