Processing result configuration for Java EE----action

Source: Internet
Author: User

1. Action return string (logical view name)
<action> find logical view names in elements corresponding to local <result>
If local <result> does not exist, it looks for global <result> (some global <global-result> can be defined in each package)


* If local <result> and global <global-result> are not found no result defined for XXX


2. Configuration <result> Each result has two properties name and type
Default Type property value Dispatcher


<result-type name= "Dispatcher" class= "Org.apache.struts2.dispatcher.ServletDispatcherResult" default= "true"/ > action forwarded to the results page
* Request.setattribute (Name,value);
* Request.getRequestDispatcher.forward ();


<result-type name= "redirect" class= "Org.apache.struts2.dispatcher.ServletRedirectResult"/> Action Redirect to results page Cannot pass properties in Request


<result-type name= "redirectaction" class= "Org.apache.struts2.dispatcher.ServletActionRedirectResult"/> Actioon Redirect to another action
* name= "redirectaction" and Name= "redirect" differ in configuration


Struts2 page Layout supports JSP, Freemarker, Velocity and other technologies
<result-type name= "Freemarker" class= "Org.apache.struts2.views.freemarker.FreemarkerResult"/> Result set using Freemarket technology
<result-type name= "Velocity" class= "org.apache.struts2.dispatcher.VelocityResult"/> result set using velocity


<result-type name= "Stream" class= "org.apache.struts2.dispatcher.StreamResult"/> File download


In enterprise development, STRUTS2 provides good AJAX support, defining the result set type= "JSON"


3. Use forwarding and redirection
<result>/demo1.jsp</result>----By default by forwarding access to demo1.jsp
<result type= "redirect" >/demo1.jsp</result>-----with redirected access to demo1.jsp


Use of Redirectaction
<action name= "redirect" class= "Cn.itcast.struts2.demo7.RedirectActionDemo" >
<result type= "Redirectaction" >
<param name= "ActionName" >hello2</param>
<param name= "namespace" >/demo2</param>
</result>
</action>

Processing result configuration for Java EE----action

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.