struts2中session最标准的实现方式

Most standard way to implement sessions in strtuts2

我一直在寻找在 struts2 中实现会话的方法。我找到了

1) 只需在 apache

上使用 getSession()
Map session = ActionContext.getContext().getSession();

2) javapoint
上使用 SessionAware 它使用的不是普通地图,而是 struts2 的一部分 SessionMap 和也是 SessionAware 的一部分。我在教程中唯一没有得到的是,它对一个 class 使用 SessionMap,对另一个 class 使用 HttpSession。


所以问题是使用 struts2 框架的会话最优雅的方式是什么?

编辑:@Romann C,你的答案,回答了如何处理sessionMap,但我想知道哪种方法最适合我。

刚才投反对票的人至少应该发表评论...

Map session = ActionContext.getContext().getSession(); 与 Struts2

结合使用

一般来说,您应该喜欢 SessionAware 界面。这使得测试更加容易,因为您不需要模拟操作上下文。

关于教程;我看不出他们使用这两种机制的原因。