What is @ModelAttribute in Spring MVC?

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

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

13条回答
  •  不要未来只要你来
    2020-11-22 09:38

    For my style, I always use @ModelAttribute to catch object from spring form jsp. for example, I design form on jsp page, that form exist with commandName

    
          
    
    

    and I catch the object on controller with follow code

    public String controllerPost(@ModelAttribute("Book") Book book)
    

    and every field name of book must be match with path in sub-element of form

提交回复
热议问题