Spring URI template, Modelandview, @ModelAttribute__spring

Source: Internet
Author: User
Spring URI Template

Uri template, equivalent to pathvariable (path variable), is used primarily to match variables in URIs, which differ from common suffix passes and appear to be more concise, and rest is recommended in this way. matches fewer precedence variables and wildcard characters, priority matches longer lengths, priority matches if the first and second are the same, and the wildcard characters are less, the precedence match can use the placeholder

A variable in the URI template can be injected using a placeholder Placeholder,placeholder through a properties file Modelandview

Holding model and View,model are models, view is views, will be parsed by Viewresolver, it is only to satisfy the method to return both the view and the data
@ModelAttribute

Can be used on a method or on a method parameter. used in the method

When used in a method, it means that the method adds one or more model attributes. It is the same type parameter as the @requestmapping method supports, but cannot map the request. Instead, @ModelAttribute method executes before the @requestmapping method executes. used on method parameters

@ModelAttribute is used on method parameters, indicating that this parameter should be fetched from model, instantiated first if not present, and then added to model. If the model has this parameter, the parameter is populated with the parameter matching the parameter field name in request, which means that the parameter's property value is populated with the request parameter.

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.