I believe this is very well described in the Struts2 documentation. All you have to do
<action name="scopea" class="ScopeActionA"> <result name="success" type="dispatcher">/jsp/test.jsp</result> <interceptor-ref name="basicStack"/> <interceptor-ref name="scope"> <param name="key">funky</param> <param name="session">person</param> <param name="autoCreateSession">true</param> </interceptor-ref> </action> <action name="scopeb" class="com.mevipro.test.action.ScopeActionB"> <result name="success" type="dispatcher">/jsp/test.jsp</result> <interceptor-ref name="scope"> <param name="key">funky</param> <param name="session">person</param> <param name="autoCreateSession">true</param> </interceptor-ref> <interceptor-ref name="basicStack"/> </action>
All you need to take care of is that you have a getter in ActionA and a similar installer in actionB. In addition, you should use a key parameter to make sure you tell Struts2 which action gets which objects
read this white paper for details of the Struts2 Scope Interceptor
I would prefer a Scope interceptor only when I need to develop magical functionality, as it will handle other things, such as session-level locking. If this is not your requirement, there is another way to pass parameters such as placing the object into the session and receiving the object from the session in the second action.
source share