Rakesh Goyal
Rakesh Goyal

Reputation: 3231

redirect struts 2 action to struts 1 action

We have been using struts 1 since long time. I don't know much about struts 2. Our company is going with component based arch. Core UI components are using struts 1. Core components will be used by old struts 1 components as well as new struts 2 components. I am not really sure if struts 1 action request can be redirected to struts 2 action or vice versa. e.g. We have a listing framework which is made in struts 1. Rendering of listing page will happen using this framework. Now if user perform any operation by selecting the record on listing screen, struts 2 action will be called and after completion of request it will be redirected back to the listing page(which is struts 1 action).

Upvotes: 0

Views: 2074

Answers (1)

Jason Wyatt
Jason Wyatt

Reputation: 31

To redirect a struts2 action to a struts1 action, put the following in your struts 2 struts.xml file:

<action name="myAction" class="myClass"  method="execute">
  <result name="success">/mystruts2page.jsp</result>
  <result name="mystruts1redirect" type="redirect">
    <param name="location">/MyStruts1Action.do?submit=View&amp;noticeId= ${nextNoticeId </param>
  </result>
  <interceptor-ref name="myInterceptorStack"/>
</action>

Note that you must use "& amp;" (with no space) and "${field}" for OGNL parameters to be parsed/passed correctly.

Upvotes: 3

Related Questions