Does anyone know if there is support for returning http code 422 from Spring MVC? I am developing some strictly RESTFul services using Spring MVC and I want to do data validations for all POST requests.
The general convention that everyone is going towards is passing the validation messages back in the body but with a 422 response.
Is there some Spring bean that I can configure which automatically returns a 422 after it executes my custom validation code?
I think you can do this with an
It has 3 methods,
preHandle is called before the request handler method is invoked, and
postHandle after the request handler method retunrs and before the view is rendered, and
afterComplete is invoked after the view is rendert.
I think you can use this to hook into the web request chain to modify request and response.