Can you explain the role of the WebApplicationContext?

WebApplicationContext is a specialized Spring ApplicationContext for web applications, extending the standard container with web-specific scopes and access to the ServletContext. It's what DispatcherServlet uses to look up controllers, view resolvers, and other web-tier beans.

Key Points

Example

In a traditional multi-module Spring MVC app, the root context loads service and repository beans shared across the whole application, while the DispatcherServlet's WebApplicationContext loads just the controllers and view resolvers needed for the web tier.

Interview Tip

A concise interview answer is

WebApplicationContext is Spring's web-aware ApplicationContext, adding request and session bean scopes and ServletContext access on top of the standard container. DispatcherServlet uses it to locate and wire up controllers and view resolvers, and in traditional apps it often sits as a child context beneath a root context holding services and repositories.

Last updated: 16 July 2026

Previous question: How do controllers and view resolvers work together during a Spring MVC request?

Next question: How do you configure Spring MVC in a web application?

More Spring MVC (Optional) interview questions

All Spring MVC (Optional) questions