applicationContext.xml
and spring-servlet.xml
related anyhow in Spring Framework?
In Servlet technology if you want to pass any input to a particular servlet then you need to pass in init param like below code.
DBController
com.test.controller.DBController
username
John
1
DBController
/DBController
If you want to pass some in put that is common for all servlets then that time you need to configure context param. Example
email
admin@example.com
SO exactly like this when ever we are working with Spring MVC we need to provide some information to Predefined servlet provided by Spring that is DispatcherServlet through init param. So the configuration is as fallows, here we are providing the spring-servlet.xml as init parameter to DispatcherServlet.
Spring MVC App
SpringController
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
/WEB-INF/spring-servlet.xml
1
SpringController
*.htm
Again we need some context param. That is applicable for whole application. So we can provide the root context that is applicationcontext.xml The configuration is like this:
contextConfigLocation
/WEB-INF/applicationcontext.xml
org.springframework.web.context.ContextLoaderListener
SpringController
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
/WEB-INF/spring-servlet.xml
1
SpringController
*.htm