Saturday, September 4, 2010

Redirect Action result to another action in struts2

Using special result type in Struts-2 result we can forward one actions result to another action before forwarding it to view logic.
"redirect-action" result type is used to achieve this.here is the sample code snippet to show how to redirect one actions result to another action


 <action name="userInfo" class="UserAction">  
  <!-- Redirect to another namespace -->  
  <result type="redirect-action">  
   <param name="actionName">getDetails</param>  
   <param name="userId">${userId}</param>  
  </result>  
 </action>  

Here after finishing userInfo action getDetails action will be invoked.Here by using "Param" tags we can pass the values to the getDetails action.

No comments:

Post a Comment