STRUTS2 configuration of a struts.xml file that jumps from one action to another action

Source: Internet
Author: User

Explain:

To jump to another action with <result>, the original configuration code is:

<action name= " Insertdept " class= method=>
<result name= "success" type = "redirect-action" >selectdept </result>
</ACTION>

   My struts version is 2.2.1, it is possible that the 2.0 version of the action configuration method has been modified, so the original configuration mode does not work. The changes are as follows:

<action Name="Insertdept" Class="Struts.org.db.DeptAction" Method="Insertdept">
   <result Name="Success" type = " redirectaction " >
<param name Span class= "pun" >= " ActionName " > selectdept </PARAM>
</RESULT>
</ACTION>

<package name= "Pack1" namespace= "/test1 " extends= "Struts-default" >
<action name= "A" class= "xxx" >
<result type= "redirectaction" >
<param name= "ActionName" >B</param>
<param name= "namespace" >/test2</param>
</result>
</action>
</package>
<package name= "Pack2" namespace= "/test2 " extends= "Struts-default" >
<action name= "B" class= "yyy" method= "Addui" >
<result name= "Success" >
/web-inf/test.jsp
</result>
</action>
</package>
Description: The above code is used to jump from an action named "a" to an action named "B" and execute the "Addui" method in action. Two action in a different package.

method Two examples:

<action name= "A" class= "xxxx" >
<result name= "Success" type= "Chain">

    <param name= "ActionName" >B</param>

<!--If you need a namespace--

    <param name= "namespace" >/xxx</param>

<!--If you need a parameter jump, make sure that there are get methods and set methods in two classes--

    <param name= "xxx" >${xxx}</param>

</result>

</action>

<!--write the method property on this class, that's how you access it--

<action name= "B" class= "xxxx" method= "xxxx" >

<result name= "Success" >/index.jsp</result>

</action>

STRUTS2 configuration of a struts.xml file that jumps from one action to another 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.