Search code examples
configurationstruts2migrationstrutsstruts-1

Navigate from Struts1 page to a Struts 2 page


We are slowly migrating our application from Struts1 to Struts 2, but for the first iteration we are simply having them run together and all new pages will be in Struts2. My problem is: how do I navigate from a strut1 page to a struts2 page?

I have a struts1 page that allows the user to select a report type. All but one selection is struts1. The last selection is a struts2 page. I need to get from the selection screen (struts1) to the new struts2 page.

Here is some code: struts-config.xml

<action path="/reporting" type="........ReportingAction" name="reportForm" input="/WEB-INF/jsps/reporting.jsp" scope="session">
    <forward name="outbound" path="/WEB-INF/jsps/reportingSelectDate.jsp">
    </forward>
    <forward name="inbound" path="/WEB-INF/jsps/reportingInboundSelectDate.jsp">
    </forward>
    <forward name="usage" path="/WEB-INF/jsps/reportingUsageSelectDate.jsp">
    </forward>
    <forward name="expansion" path="/s2/expansionReportEntry.jsp">
    </forward>
    <forward name="failure" path="/WEB-INF/jsps/reporting.jsp">
    </forward>
    <forward name="login" path="/login.do">
    </forward>
</action>

I want to forward "expansion" to the new Struts 2 page. Is this the correct way to go about it? Assuming I have struts.xml and web.xml set up correctly. I have struts2 filter handling .action and struts1 doing .do.


Solution

  • The right way is to redirect to the new framework, even if maintaining two frameworks is not recommended

    <forward name="expansion" path="/s2/expansionReportEntry.action" redirect="true">