Dispatcher is the default jump type and is used to return a view Resource (such as JSP)
XML code:
<Result name = "success">/Main. jsp </result>
<Result name = "success">/Main. jsp </result>
The preceding statement uses two default statements. The complete statement is as follows:
<Result name = "success" type = "dispatcher">
<Param name = "location">/maini. jsp </param>
</Result>
For page forwarding, the page Jump process is always the same thread, and the data in the action is always saved in.
Location can only be a page, not another action (available type = "chain ).
The redirect type is used to redirect to a page, another action, or a URL.
XML code:
<Result name = "success" type = "Redirect"> AAA. jsp </result>
<Result name = "success" type = "Redirect"> BBB. Action </result>
<Result name = "success" type = "Redirect"> www.baidu.com </result>
Disadvantage: Redirect resends an HTTP return code (SUCCESS) along with the returned page location to the Web server, which then generates a new HTTP request, A new thread is generated, and data stored in the thread where the original action is executed cannot be accessed.
Therefore, the result must contain the action data, So redirect is not a feasible method. Because the new HTTP request is processed in the new thread of the servlet container, no status exists in the actioncontext.
Solution:
(Method 1 ):
<Result name = "topic" type = "Redirect">/topicaction! Findtopics. do? Topicid =$ {topicid} </result>
(Method 2 ):
<Result name = "topic" type = "Redirect-action">
<Param name = "actionname"> findtopics </param>
<Param name = "topicid" >$ {topicid} </param>
</Result>
The redirect-action result type uses the actionmapper provided by actionmapperfactory to redirect the request to another action.
XML code:
<Result name = "Err" type = "Redirect-action">
<Param name = "actionname"> redirected action name </param>
<Param name = "namespace"> The namespace of the Redirection action </param>
</Result>
There is no difference in the use of redirect and redirect-action results, but they are written differently.
Chain is used to connect several related actions to complete a function.
XML code:
<Action name = "Step1" class = "test. step1action">
<Result name = "success" type = "chain"> step2.action </result>
</Action>
<Action name = "step2" class = "test. step2action">
<Result name = "success"> finish. jsp </result>
</Action>
Action in the chain belongs to the same HTTP request and shares an actioncontext
The plaintextj result type is used to display source code directly on the page.
XML code:
<Result name = "Err" type = "plaintext">
<Param name = "location"> location </param>
<Param name = "charset"> character specifications (such as GBK) </param>
</Result>