What is @ModelAttribute in Spring MVC?

后端 未结 13 1130
一个人的身影
一个人的身影 2020-11-22 08:43

What is the purpose and usage of @ModelAttribute in Spring MVC?

13条回答
  •  生来不讨喜
    2020-11-22 09:21

    The ModelAttribute annotation is used as part of a Spring MVC Web application and can be used in two scenarios.

    First of all, it can be used to inject data into a pre-JSP load model. This is especially useful in ensuring that a JSP is required to display all the data itself. An injection is obtained by connecting one method to the model.

    Second, it can be used to read data from an existing model and assign it to the parameters of the coach's method.

    refrence https://dzone.com/articles/using-spring-mvc%E2%80%99s

提交回复
热议问题