SteelReed

Search

Search posts, questions…

Spring BootQuestion 17 / 26

Middle

Walk through the path of a request in Spring MVC via the DispatcherServlet?

Short answer

The request passes the filter chain to DispatcherServlet; it asks HandlerMapping for the controller, uses a HandlerAdapter to call the method, then writes JSON or renders a view. Exceptions go to a HandlerExceptionResolver, which is where @ControllerAdvice lives.

exceptionFilter chainDispatcherServletHandlerMappingcontroller + interceptorsHandlerAdapterbind args, call methodMessage converterwrites JSONHandlerExceptionResolver@ControllerAdvice

3 points to say:

  1. Filters → DispatcherServlet → HandlerMapping → interceptors → HandlerAdapter → converter or view.
  2. Argument resolvers bind parameters, message converters read/write the body.
  3. Exceptions go through HandlerExceptionResolver (@ControllerAdvice); customize with WebMvcConfigurer, don't add @EnableWebMvc.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.