@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