Visibility interceptor in struts2

Is there any code example where I can see the use of an area interceptor in Struts2? I want to pass a parameter from one action to another action (configured through struts.xml) and want to use an area interceptor.

Since I'm new to Struts 2, can anyone provide a sample on how to use the scope interceptor?

+1
source share
1 answer

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.

+2
source

All Articles