Spring MVC Redirectattributes

Source: Internet
Author: User

Org.springframework.web.servlet.mvc.support.RedirectAttributes

 Case if the method returns a "redirect:" Prefixed view name or Redirectview.

This class is used to store the specified set of properties, including some property parameters for redirection and some temporary property information (these properties are stored in the server's staging space, so that they are still available for request after redirection). When the method returns a "redirect:" prefix for the view name or redirect view, Redirectattributes is used to replace the implied model property.

The default all model attributes is considered to being exposed as URI template variables in the redirect URL. Of the remaining attributes those that is primitive types or collections/arrays of primitive types is automatically AppE nded as query parameters.

By default, all model properties are considered to expose URI template variables in redirected URLs. The remaining primitive type properties, or the collection or array properties of the original type, are appended to the query parameters automatically.

 for  for default Model is used.

However, in the control class for annotations, the model may contain additional attributes that were originally added to be used for the purpose of submission. For precise control, through the property information in the redirection scheme, a @requestmapping method can declare a parameter of type redirectattributes and use that property in Redirectview. If the controller is redirected, the content in the redirectattributes will be used. Otherwise, the content in the default model is used.

 The Requestmappinghandleradapter provides a flag called "ignoredefaultmodelonredirect" that can being used to indicate t He content of the default  Model should never be used  a controller method redirects. Instead The Controller method should declare an attribute of type Redirectattributes or if
      it doesn ' t do  so no attributes should is passed on to Redirectview. Both the MVC namespace and the Mvc Java config keep this  flag set to false  in order to maintain backwards compatibility. However, for  true  

Requestmappinghandleradapter provides an identifier named "Ignoredefaultmodelonredirect" that can be used to indicate which content in the default model should never be used when a controller method is redirected. The opposite controller method should declare a Redirectattribute property, or when it does not do so, there should be no property passed to Redirecview. The MVC namespace and the Mvcjava configuration need to declare this identity false, in order to preserve backward compatibility. However, we recommend setting true for new applications.

Interface  Do  for  for Flash attributes in Spring MVC.

This redirectattributes interface can be used to add temporary properties. Unlike the redirect parameters that end in the destination redirect URL, the temporary attributes are recorded in the session (and will not appear in Rul in the future). The model of the controller provides the destination redirect address to automatically receive these zero parameters when they are removed from the session. Section 17.6 describes how SPRINGMVC supports temporary property information

Spring MVC Redirectattributes

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.