Struts2 How to move from one action to another

Source: Internet
Author: User

In Struts2, when the action finishes processing a user request, a string object is returned, which is a logical view name. Struts 2 by configuring the mapping relationship between the logical view name and the physical view, once the system receives a logical view name returned by the action, the system renders the corresponding physical view to the viewer.

The result type of Struts 2 determines that after the action is finished, the next step is to call that view resource to render the processing result. The default is dispatcher, which specifies that the JSP is used as the view resource. But we have the requirement that we move from one action to another.

By jumping from one action to another, struts provides two types of results: chain, redirect.


<action name= "Sousuo" class= "com.sunlawer.action.SearchAction" >
    		<result>/index.jsp</result >
    		<result name= "Lawerlist" type= "Chain" >lawerListAction</result>
    		<result name= "Anli" Type= "Chain" >lawerCaseAction</result> <result name= "Zaixianzixun" type= "Chain
    		" >zaixianzixun </result>
    	</action>
Among them, Lawerlistactiion and Lawercaseaction and Zaixianzixun are the names of the target action to go to, which are already configured in the Struts2 configuration file. For example:

<action name= "lawerlistaction" class= "com.sunlawer.action.LawerAction" >
    		<result name= "Success" >/ Lushijieshao.jsp</result>
    	</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.