I have code that looks like this:
Controller
public String doStuff(@Valid @RequestBody MyClass obj, BindingResult result) {
...
}
Validation
@InitBinder
public void initBinder(WebDataBinder binder, HttpServletRequest request) {
binder.setValidator(new MyValidator());
}
The problem is that I don't know how to "hook up" the obj param with the specific initBinder method I need to run to automagically validate obj with my custom Validator class. I need some way to have a specific @InitBinder method run after the obj param is bound to the request body.
Also, I have to use @RequestBody since the controller method is taking in a JSON payload in the request body.