Web Framework Internals interview question · Most asked

Describe the Spring MVC request flow and where exceptions are handled.

Summary

Filter chain (including Spring Security) → DispatcherServlet → HandlerMapping → HandlerInterceptor.preHandle → argument resolution, message conversion and @Valid → controller → return value written (or view rendered after postHandle) → afterCompletion. Exceptions thrown inside the DispatcherServlet are handled by exception resolvers such as @ControllerAdvice; exceptions in filters are not.

Longer Answer

For authentication errors in Spring Security, use AuthenticationEntryPoint and AccessDeniedHandler to keep the API's error format.

Key Points

  • Filters → DispatcherServlet → interceptors → controller.
  • Message converters and validation.
  • @ControllerAdvice inside MVC only.
  • Security handlers for filter-level errors.

Deep dive: Request Lifecycle: Spring Boot: Filters, DispatcherServlet and Interceptors

Explanation

What interviewers look for

Correct order and exception-handling boundaries.

More most-asked Web Framework Internals questions

← All Web Framework Internals questions