When the default is,<result> TagsThe value of the type attribute is "dispatcher" (which is actually forwarding, forward). Developers can specify different types depending on their needs, such as redirect, Stream, and so on. As shown in the following code: <result name= "Save" type= "redirect" >/result.jsp </result> At this point Result-type can be in the Struts2-core-2.0.11.1.jar package or struts2 source codeStruts-default.xmlFound in the file, found in this file<result-types>tags, all the result-type are defined inside.
Configured result type name |
Class name |
Description |
Dispatcher |
Org.apache.struts2.dispatcher. Servletdispatcherresult |
Default result type, used to render JSP pages |
Chain |
Com.opensymphony.xwork2. Actionchainresult |
Link an action with another action |
Freemarker |
Org.apache.struts2.views.freemarker. Freemarkerresult |
Rendering Freemarker Templates |
Httpheader |
Org.apache.struts2.dispatcher. Httpheaderresult |
Returns a configured HTTP header message response |
redirect |
Org.apache.struts2.dispatcher. Servletredirectresult |
Redirect the user to a configured URL |
Redirectaction |
Org.apache.struts2.dispatcher. Servletactionredirectresult |
Redirect the user to a defined action |
Stream |
Org.apache.struts2.dispatcher. Streamresult |
Pass the raw data back to the browser as a stream. This result type is useful for downloaded content and pictures |
Velocity |
Org.apache.struts2.dispatcher. Velocityresult |
Render Velocity Template |
Xslt |
Org.apache.struts2.views.xslt. Xsltresult |
Renders XML to the browser, The XML can be converted through an XSL template |
PlainText |
Org.apache.struts2.dispatcher. Plaintextresult |
Returns the normal text class capacity |
Dispatcher: For page forwarding, the page jump process is always the same thread, and the data in the action is kept in. Redirect: can be used to return a page, an action, link to a URL.
Cons: Redirect sends an HTTP return code (SUCCESS) and the returned page location back to the Web server, which, after being accommodated by the Web server, generates a new HTTP request, creating a new thread. Data stored in the thread that was executed by the original action cannot be accessed. Therefore, result needs to contain the data of the action, then redirect is not a feasible approach. Because new HTTP requests are processed in the new thread of the servlet container, all states in the Actioncontext do not exist. Chain: The feature is similar to redirect's action forwarding, but unlike the redirectaction forwarding feature, it can keep the data in the action in the same HTTP request all the time.
"Strust" Strust.xml <result type= "" > All Types