What is the difference between Application Context and Web Application Context?
I am aware that WebApplicationContext
is used for Spring MVC architectur
Going back to Servlet days, web.xml can have only one
, so only one context object gets created when server loads an application and the data in that context is shared among all resources (Ex: Servlets and JSPs). It is same as having Database driver name in the context, which will not change. In similar way, when we declare contextConfigLocation param in
Spring creates one Application Context object.
contextConfigLocation
com.myApp.ApplicationContext
You can have multiple Servlets in an application. For example you might want to handle /secure/* requests in one way and /non-seucre/* in other way. For each of these Servlets you can have a context object, which is a WebApplicationContext.
SecureSpringDispatcher
org.springframework.web.servlet.DispatcherServlet
contextClass
com.myapp.secure.SecureContext
SecureSpringDispatcher
/secure/*
NonSecureSpringDispatcher
org.springframework.web.servlet.DispatcherServlet
contextClass
com.myapp.non-secure.NonSecureContext
NonSecureSpringDispatcher
/non-secure/*