Project record: Springmvc forward redirect problem

Source: Internet
Author: User

@RequestMapping ("/redirect")
Public String Redirect (Redirectattributes redirectattributes) {
Redirectattributes.addflashattribute ("Test", "testdata"); Used in this case.
return "Redirect:read";
}

Note: In this case, the URL will jump along with a Request variable named "test", i.e. the value "testdata" can be obtained with ${request["test"} or ${test} in its directed template file

In the normal redirect jump, it is impossible to save the request variable.

If in the above, using the traditional method to set the parameters Modelmap model, the method body with model.setattributes ("Test", "testdata"); Instead of redirectattributes in this way, the request variable cannot be saved in the jump.

This feature, can be used to prevent users to refresh the URL repeatedly submit data, but also to the page has been jumped to pass some information.

@RequestMapping ("/read")//equivalent to forward
Public String test () {
return "Test/read";
}

@RequestMapping ("/forward")
Public String Forward (Modelmap model) {
Model.addattribute ("Test", "test data from forward");
return "Test/read";
}

In the case of forward, it is not possible to use the Redirectattributes property. It is also not possible to prevent users from refreshing pages that repeatedly submit data

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.