"Strust" Strust.xml <result type= "" > All Types

Source: Internet
Author: User
Tags xslt

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.