先调用request的getSession()方法获取一个HttpSession的对象,然后将这个对象进行强制类型转换成原本封装的对象,这样就能获取Session对象中的对象了
1、调用request的getSession()方法
HttpSession session = request.getSession();
2、强制类型转换
User user = (User) session.getAttribute("session_user");
先调用request的getSession()方法获取一个HttpSession的对象,然后将这个对象进行强制类型转换成原本封装的对象,这样就能获取Session对象中的对象了
1、调用request的getSession()方法
HttpSession session = request.getSession();
2、强制类型转换
User user = (User) session.getAttribute("session_user");