Result is also a relatively important part of Struts2. There are four types commonly used in the configuration of Result: dispatcher, redirect, chain and redirectAction. Among these four, the former two are the most common.
example:
<struts> <constant name="struts.devMode" value="true" /> <package name="resultTypes" namespace="/r" extends="struts-default"> <action name="r1"> <result type="dispatcher">/r1.jsp</result> </action> <action name="r2"> <result type="redirect">/r2.jsp</result> </action> <action name="r3"> <result type="chain">r1</result> </action> <action name="r4"> <result type="redirectAction">r2</result> </action> </package> </struts>
1. dispatcher , the most commonly used - server-side jump, that is, when a user accesses an Action, the background server will search for which jsp page the corresponding result is, and then jump. At this time, the address of the action is displayed in the browser's address bar.
2. Redirect is also commonly used. Client jumps. This jump is more interesting. First, when the user visits the server, the server will give the user a feedback. The user will resend a request server based on this feedback. This request is the page request to be viewed, and the server will directly display the page to the user. There are two requests in the process. In this way, the URL address in the browser is the address of the jsp file.
3. chain , chain, it is an action accessed in the forward method, which can be inside the package or outside the package. His browser URL is the address of action
4. redirectAction , jump to other Actions in the redirect method, so its browser URL displays the address of the jsp file it accesses
The above is the full content of the four commonly used types of Result in Struts2. I hope it can give you a reference and I hope you can support Wulin.com more.