I am migrating an application from Struts1 to Struts2. I could migrate everything except the scope
attribute from the below action tag of the Struts1 configuration file (struts-config.xml
).
Struts1 configuration:
<action path="/DomainAndIPBlocking"
type="com.tarangtech.da.struts.action.DomainBlockedListAction"
name="DomainBlockForm"
scope="session"
input="/DomainAndIPBlocking.do"
validate="false">
<forward name="success" path="/jsp/SystemAdminConsol/DomainBlocking.jsp"/>
</action>
Migrated Struts2 configuration:
<action name="DomainAndIPBlocking"
class="com.tarangtech.da.struts.action.DomainBlockedListAction"
method="execute">
<result name="success">/jsp/SystemAdminConsol/DomainBlocking.jsp</result>
</action>
The form DomainBlockForm
has been integrated by extending the action class DomainBlockedListAction
like this:
public class DomainBlockedListAction extends DomainBlockForm
It is required for me to carry forward the form values across the application. But these values are available in request/page scope only. So, I should have an alternative for scope="session" from Struts1 to Struts2, so that I can carry forward all the attributes across the application.
From the Struts 1 DTD in the Action Element definition:
In Struts 2, there are no Action Form beans, and Actions themselves default to request context. @meskobalazs is correct above, this can be overridden with the scope interceptor if you need session-scoped actions in Struts 2.