Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是新手,第一次发帖...我有一个问题要问,在 struts2 中,我想在实现会话时在动作之间传递对象/数据。假设我有一个动作 A,它有一个名为“myStr”的字符串,甚至是一个名为 myObj 的对象,那么如何在动作之间传递时使其在整个会话中可用?actionA-->calls actionB--> actionC..blah blah ...但是必须在任何动作类中访问 myStr 或 myObj 的值。你能指导我正确的方向吗?
使用 REQUEST 属性时需要传递值。
当您将属性放入 SESSION 中时,它们将在会话的整个生命周期内一直存在(除非您明确删除它们)。
随时随地,直到会话有效,您将通过调用来检索它们session.get("myKey")
session.get("myKey")