Spring MVC 3.0: How do I bind to a persistent object

后端 未结 4 405
面向向阳花
面向向阳花 2020-12-10 07:59

I\'m working with Spring MVC and I\'d like it to bind a a persistent object from the database, but I cannot figure out how I can set my code to make a call to the DB before

4条回答
  •  一整个雨季
    2020-12-10 08:38

    So I ended up resolving this by annotating a method with a @ModelAttribute of the same name in the class. Spring builds the model first before executing the request mapping:

    @ModelAttribute("item")
    BenefitType getBenefitType(@RequestParam("id") String id) {
        // return benefit type
    }
    

提交回复
热议问题