Type attribute of struts2 result

Source: Internet
Author: User

Currently, only the following three types are used.

Chain:

Statement: <result name = "success" type = "chain"> nextaction </result>

The slash (/) is not added before nextaction. the value set in the request in the previous action can be obtained in nextaction.

Redirect:

Statement: <result name = "success" type = "Redirect"> nextaction </result>

You can add or remove a slash before nextaction. the value set in the request in the previous action is lost and cannot be obtained in nextaction.

However, you can use 【?] Use [&] instead of [& amp ;]

<Result name = "success" type = "Redirect"> nextaction? Nextform. Property =$ {currentform. Property} & amp; nextform. Property =$ {current. Property} </result>

Nextaction must have the get and set methods of nextform. If it is an attribute, it must also have the get and set methods to get the value.

Private nextform = new nextform ();
Public nextform getnextform (){
Return nextform;
}
Public void setnextform (nextform ){
This. nextform = nextform;
}

Redirectaction:

Statement: <result name = "success" type = "redirectaction"> nextaction </result>

The slash (/) is not added before youraction. the value set in the request in the previous action is lost and cannot be obtained in nextaction.

However, you can use 【?] Use [&] instead of [& amp ;]

<Result name = "success" type = "Redirect"> nextaction? Nextform. Property =$ {currentform. Property} & amp; nextform. Property =$ {current. Property} </result>

Nextaction must have the get and set methods of nextform. If it is an attribute, it must also have the get and set methods to get the value.

Private nextform = new nextform ();
Public nextform getnextform (){
Return nextform;
}
Public void setnextform (nextform ){
This. nextform = nextform;
}

Note: The difference between redirect and redirect-action

I. using Redirect requires a suffix. Using redirect-action does not require a suffix. However, in actual use, redirect does not require a suffix. In the same package, different packages have not been tried.
2. The value of type = "Redirect" can be transferred to actions in other namespaces, while redirect-action can only be transferred to actions under the same namespace, so it can be omitted. the suffix of the action directly writes the name of the action.

Type attribute of struts2 result

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.