Spring MVC Missing request attribute

前端 未结 1 1906
鱼传尺愫
鱼传尺愫 2021-01-24 08:11

So i\'m currently taking a course on udemy about Spring MVC. In the current section there\'s a simple form being build to submit firstname and lastname.

Hey user         


        
相关标签:
1条回答
  • 2021-01-24 08:40

    You are using the wrong annotation. @RequestAttribute is for retrieving attributes set on the HttpServletRequest using setAttribute. You however want to bind request parameters to an object, for that you should use the @ModelAttribute annotation instead.

    @RequestMapping("/hello")
    public ModelAndView helloWorld(@ModelAttribute("info") Information userInfo) { ... }
    

    Changing the annotation will make it work.

    0 讨论(0)
提交回复
热议问题