DispatcherServlet explained
DispatcherServlet
is the gateway to any Spring MVC application. Inherited from javax.servlet.http.HttpServlet
, it is typically configured declaratively in the web.xml
file. While you can have multiple definitions of DispatcherServlet
with unique URL patterns, most Spring MVC applications only have single DispatcherServlet
with the context-root
URL(/
), that is, all requests coming to that domain will be handled by DispatcherServlet
.
Starting from Servlet 3.0, in addition to declarative configuration in the web.xml
file, DispatcherServlet
can be configured programmatically by implementing or extending either of these three support classes provided by Spring:
- The
WebAppInitializer
interface - The
AbstractDispatcherServletInitializer ...
Get Spring MVC: Designing Real-World Web Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.