如何在Spring MVC 3中获取会话信息 [英] How to get session information in Spring MVC 3

查看:131
本文介绍了如何在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.

这篇关于如何在Spring MVC 3中获取会话信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆