The difference between chain, redirect and Redirectaction in Struts2
Article Summary:
First, Chain Result:
This result invokes an additional action that connects to its own interceptor stack and result.
? ActionName (default)-The name of the action being invoked
? namespace-The name space of the action being invoked. If the namespace is empty, this implicitly considers the current namespace
Method-The other way to specify the target action is called. If empty, the default is the Excute method
Redirect Action Result:
This result uses the Actionmapper provided by Actionmapperfactory to reposition the browser's URL to invoke the specified action and (optional) namespace. This result is better than servletredirectresult. Because you do not need to encode the URL into the schema provided by the Actionmapper configured in Xwork.xml. This means that you can change the URL pattern at any point without affecting your application. It is therefore highly recommended to use this result instead of the standard redirect result to resolve the relocation to an action.
? ActionName (default)-The action name to relocate to
The name space of the namespace-action. If null, the current namespace
?
Redirect Result
Call {@link httpservletresponse#sendredirect (String) Sendredirect} method to go to the specified location. The HTTP response is told to allow the browser to jump directly to the specified location (resulting in a new request from the client). The result of this is that the action you just executed (including the action instance, the error message in action, and so on) is lost and is no longer available. This is because the action is built on a single-threaded model. The only way to pass data is through a session or a Web parameter that can be a OGNL expression (url?name=value)
Location (default)-the address that the action jumps after execution.
? Parse-default is true. If set to False, the location parameter is not parsed as an OGNL expression.
Two. When you use type= "redirectaction" or type= "redirect" to commit to an action and need to pass a parameter. Here are the differences:
A. When using Type= "Redirectaction", the result is only the configuration name of the action, not the suffix: ". Action"
Java code
<action name= "Login" class= "Steven.actions.LoginAction" >
<result name= "Success" type= "Redirectaction" >User?u_id=${loginBean.u_id}</result>
</action>
B. When using type= "redirect", the result should be the action configuration name + suffix name
Java code
<action name= "Login" class= "Steven.actions.LoginAction" >
<result name= "Success" type= "redirect" >User.action?u_id=${loginBean.u_id}</result>
</action>?
Ps:1 redirect:action after processing, redirect to a view resource (such as: JSP page), request parameters are all lost, action processing results are all lost.
2 redirect-action:action after processing, redirect to an action, request parameters are all lost, action processing results are all lost.
<result name= "Deleteok" type= "Redirect-action" >/user/login!operatorList.action</result>
3 chain:action after processing is forwarded to an action, request parameters are all lost, action processing results are not lost.
The difference between chain, redirect and Redirect-action in Struts2