Handling form submission in Spring MVC means binding HTTP POST data to a Java object, validating it, and responding appropriately — either re-showing the form with errors or proceeding after success.
A registration form posts to /register, binds to a User object via @ModelAttribute, and if BindingResult.hasErrors() is true the method returns back to the registration view with error messages instead of proceeding.
@PostMapping("/register")
public String register(@Valid @ModelAttribute User user,
BindingResult result) {
if (result.hasErrors()) {
return "registerForm";
}
userService.save(user);
return "redirect:/success";
}A concise interview answer is
I use @PostMapping with @ModelAttribute to bind form fields onto a Java object, add @Valid to trigger bean validation, and capture errors with a BindingResult parameter right after it. If there are errors I return back to the form view, otherwise I process the data and redirect to avoid duplicate submissions.
Last updated: 16 July 2026
Previous question: How do you manage form data in Spring MVC?
Next question: What is the role of the @ModelAttribute annotation?