-
Couldn't load subscription status.
- Fork 38.8k
Closed as not planned
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)
Description
After upgrading from spring-boot 2.7 to spring-boot 3.4, implicit @ModelAttribute annotation doesn't work anymore.
@Autowired
MyBeanValidator myBeanValidator;
@ModelAttribute("myBean")
public MyBean getMyBean() {
return new MyBean();
}
@PostMapping("/addMyBean")
public String doAddMyBean(@ModelAttribute MyBean myBean, BindingResult result) {
myBeanValidator.validate(myBean, result);
if(result.hasErrors()) {
return "add-my-bean";
}
...
}Doing this doesn't work anymore: in case of validation error, form is displayed empty and error messages are not displayed (#fields.hasErrors does not trigger) as if the backing bean was cleared.
Using explicit @ModelAttribute name fixes the problem :
@PostMapping("/addMyBean")
public String doAddMyBean(@ModelAttribute("myBean") MyBean myBean, BindingResult result) {
return "add-my-bean";
}Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)