#spring-mvc
Posts
-
Digging into Spring's Source 21: DispatcherServlet — How One Request Becomes a Response
We follow a single HTTP request through Spring MVC by reading the source of DispatcherServlet. Written for people new to Spring, it covers how the servlet sets up its own context and strategy objects at startup, and the order in which doDispatch finds a handler, calls it, and weaves in interceptors and exception handling.
-
Digging into Spring's Source 22: Handler Mappings and Adapters — How @RequestMapping Methods Are Found and Called
When and where a method annotated with @GetMapping gets registered, which of several candidate methods wins for a request, who fills in the chosen method's arguments, and who turns its return value into a response — followed through the source of RequestMappingHandlerMapping and RequestMappingHandlerAdapter. Examples show the two different "ambiguous mapping" errors and exactly where a custom argument resolver slots in.
-
Digging into Spring's Source 23: Exception Handling, Interceptors, Views — Before, After, and the End of a Request
How HandlerInterceptors that run around a controller method are lined up and why only the ones whose preHandle passed get afterCompletion, in what order an exception thrown by a controller travels through the HandlerExceptionResolvers until it reaches an @ExceptionHandler method, and how a single view name goes through ViewResolver and View to end in a forward to a JSP — all checked against the real source and the output of small examples.