Why can't I redirect an action to another action in Struts2?

I am using Struts2. I have a dialog box with a list of faces that is updated through the action "search_users". Next to this list, I have a form that you can use to add another person by calling the add_user action when submitting the form.

What I'm trying to do is that after the add_user action is completed, the list is updated using the "search_user" action.

I tried using the redirect result type in struts.xml as follows:

<action name="search_users" class="org.apache.struts.gestion_edt.controller.adm_proyectos.BLSubequipo" method="searchUsers"> <result name="success">list.jsp</result> </action> <action name="add_user" class="org.apache.struts.gestion_edt.controller.adm_proyectos.BLTipoEntregable" method="addUser"> <result name="success" type="redirectAction">search_users</result> </action> 

But that does not work. What am I doing wrong? Is there something I should add to the struts.xml file that I don't know about?

This is the mesage error I get:

 "Caused by: There is no result type defined for type 'redirect-action' mapped with name 'success'. Did you mean 'redirectAction'? - result - file:/.../struts.xml:59:44 at ..." 
+7
source share
3 answers

Current configuration:

 <action name="add_user" class="org.apache.struts.gestion_edt.controller.adm_proyectos.BLTipoEntregable" method="addUser"> <result name="success" type="redirectAction">search_users</result> </action> 

According to the documentation, the correct format is:

 <action name="add_user" class="org.apache.struts.gestion_edt.controller.adm_proyectos.BLTipoEntregable" method="addUser"> <result type="redirectAction"> <param name="actionName">search_users</param> <!--<param name="namespace">/secure</param> This is optional if your action where you are redirecting is in the same namespace you can leave this, if your action is in some other name space then provide the namespace--> </result> </action> 
+12
source

Currently using Struts 2.3.20 , this works:

 <result type="redirectAction">myAction</result> 

I did not confirm in previous versions.

+2
source

I'm not a big Struts guy, but based on the documentation, it looks like your forwarding is not syntactically correct: http://struts.apache.org/2.1.6/docs/redirect-action-result.html

 <package name="public" extends="struts-default"> <action name="login" class="..."> <!-- Redirect to another namespace --> <result type="redirect-action"> <param name="actionName">dashboard</param> <param name="namespace">/secure</param> </result> </action> </package> 
0
source

All Articles