Google News
logo
Java Springs - Interview Questions
What is DispatcherServlet and ContextLoaderListener?
DispatcherServlet is the front controller in the Spring MVC application and it loads the spring bean configuration file and initializes all the beans that are configured. If annotations are enabled, it also scans the packages and configures any bean annotated with @Component, @Controller, @Repository, or @Service annotations.
 
ContextLoaderListener is the listener to start up and shut down Spring’s root WebApplicationContext. Its important functions are to tie up the lifecycle of ApplicationContext to the lifecycle of the ServletContext and to automate the creation of ApplicationContext. We can use it to define shared beans that can be used across different spring contexts.
Advertisement