[Spring MVC]-view of redirect and forward

Source: Internet
Author: User

You can go to another action for continuous processing by redirect/forward:url way.
You can prevent a form from repeating commits by Redirect:url.
The wording is as follows:
return "Forward:/order/add";
return "redirect:/index.jsp";

With parameter redirection--redirectattributes
After the user saves or modifies, in order to prevent the user to refresh the browser (F5) causes the form to repeat commits, generally after the save or the modification operation will redirect to a result page (not forward), simultaneously carries the parameter, such as the operation successful prompt message. Because the attribute in the redirect,request will not pass the past. Spring provided this capability--redirectattributes at 3.1. Repeated press F5, the operation of the successful message will not come out again (a total of only one time), the effect is ideal.

Java code

 Public String Save (@ModelAttribute ("group") group group, Redirectattributes redirectattributes) {    Accountmanager.savegroup (group);    Redirectattributes.addflashattribute ("message", "Operation succeeded");     return "redirect:/account/group/";}

[Spring MVC]-view of redirect and forward

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.