How to add Params in struts2 @ result Annotation

Source: Internet
Author: User

Refer:

Http://struts.apache.org/2.0.11/docs/result-annotation.html

Http://jdkcn.com/entry/add-params-to-struts2-result-annotation.html

 

In the original webwork xml configuration file, you can add some additional parameters to the <result> node under <action>.
<Result...>
<Param name = "">... </param>
</Result>
What should I do after changing to @ result annotation.

View @ resultSource codeA Params string array is found.

@ Retention (retentionpolicy. runtime)
Public @ interface result {
String name () default action. success;
Class type () default nullresult. Class;
String Value ();
String [] Params () default {};
}

However, the original Param configuration is a key-value pair of key and value. Later I found the struts2 document, which originally stipulated the key and value in the string array.

    • Params-an array of the parameters in the form {key1, value1, key2, value2}

@ Result (name = "error", type = freemarkerresult. Class, value = "/error. FTL", Params = {"contenttype", "application/XML "})

What about passing parameters?

@ Result (name = "success ",
Type = "redirectaction ",
Location = "D-list ",
Params = {"ID", "% {ID }""}
)

 

In this way, when return success is returned, it will jump to D-list? Id = xxxx

 

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.