Your understanding is correct. The ApplicationContext is where your Spring beans live. The purpose of the ContextLoaderListener is two-fold:
-
to tie the lifecycle of the
ApplicationContextto the lifecycle of theServletContextand -
to automate the creation of the
ApplicationContext, so you don’t have to write explicit code to do create it – it’s a convenience function.
Another convenient thing about the ContextLoaderListener is that it creates a WebApplicationContext and provides access to the ServletContext via ServletContextAware beans and the getServletContext method.