The Spring MVC infrastructure is complex. There are a lot of pieces that come together to invoke your @Controller
handler method. I explain some of it in my answer here.
In summary, Spring MVC scans your @Controller
classes for @RequestMapping
annotated methods. It creates mappings for these in a RequestMappingHandlerMapping
and uses a RequestMappingHandlerAdapter
to dispatch to them, ie. invoke your handler methods.
Before it invokes the method, it goes through a couple of housekeeping steps. You can see these in the source code, here. The short version is:
- It wraps the
HttpServletRequest
and HttpServletResponse
in an adapter.
- It creates factories producing
Model
and WebDataBinder
instances (the latter come from your @InitBinder
methods).
- It creates a
ServletInvocableHandlerMethod
which encapsulates the invocation of your handler method with HandlerMethodArgumentResolver
to generate arguments for your handler method and HandlerMethodReturnValueHandler
to process the return value of your handler method.
- It creates a
ModelAndViewContainer
which will potentially be used to later render a view as the HTTP response.
- It prepares an async environment in case the request uses async components.
Then it invokes the method.
That WebDataBinder
object you're curious about is stored and used in various places in the execution context described above.