如何在Spring MVC 3中获取会话信息
我是初级MVC的新手,我正在尝试在我的控制器类中获取会话信息
I am new to spring MVC and I am trying to get the session information in my controller class
现在我正在使用
HttpSession objHttpSession = request.getSession(true);
HttpSession objHttpSession = request.getSession(true);
如果我想要获取会话创建时间和会话ID我正在使用
if I want to get session creation time and session Id I am using
objHttpSession.getCreationTime();
objHttpSession.getId();
objHttpSession.getCreationTime(); objHttpSession.getId();
我想知道是否有任何Spring MVC特定方式来获取会话详细信息?
I want to know is there any spring MVC specific way to get the session details?
提前致谢
我通常声明一个类型的参数当我需要访问会话详细信息时,我的Spring MVC控制器方法中的HttpSession。
I usually declare a parameter of type HttpSession in my Spring MVC controller method when I need to access session details.
例如:
@RequestMapping("/myrequest")
public void handleMyRequest(HttpSession session, ...) {
...
}
我认为这是最简单的方法,但不知道它是否符合您的需求。
I think it's the simplest way, but don't know if it fits your needs.