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
- Where should authentication, authorisation, validation and error formatting live in a web framework?
- How does Express handle a request, and how are errors routed?
- What is the NestJS request lifecycle?
- What is a request lifecycle, and why should a backend engineer know it for their framework?
- Walk through the Laravel request lifecycle and say where you would add code that must run on every request.
- What layers does a request pass through before reaching application code, and how should their timeouts relate?
- Walk through the Django request lifecycle.
- What happens in the browser from navigation to an interactive single-page app?