Spring: @ModelAttribute VS @RequestBody

后端 未结 7 500
闹比i
闹比i 2020-12-04 16:19

Please correct me if I am wrong. Both can be used for Data Binding.

The question is when to use @ModelAttribute?

@RequestMapping(val         


        
7条回答
  •  猫巷女王i
    2020-12-04 16:49

    I think @ModelAttribute and @RequestBody both are having same use, only difference is @ModelAttribute use for normal spring MVC and @RequestBody use for REST web service. It is @PathVariable and @PathParam. But in in both the cases we can mix it. we can use @PathVariable in REST and vice versa.

提交回复
热议问题