I am new in Spring and registering a user.I did like this.
@RequestMapping(\"/register\")
public String register(@ModelAttribute User user,BindingResult
Looking at current (Spring 5.1.5) documentation (https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc-ann-arguments):
Controller method argument - Any other argument [GP - without annotation]:
If a method argument is not matched to any of the earlier values in this table and
it is a simple type (as determined by BeanUtils#isSimpleProperty),
it is a resolved as a @RequestParam. Otherwise, it is resolved as a @ModelAttribute.
So if you have a non simple property as parameter in a controller mapped method, it's the exact equivalent of annotating it as @ModelAttribute
.