The main difference in responsibility
dispatcher-servlet.xml file contains all of your configuration for
Spring MVC. So in it you will find beans such as
Interceptors and so forth. All of these beans are part of
Spring MVC which is a framework that structures how you handle web requests, providing useful features such as databinding, view resolution and request mapping.
application-context.xml can optionally be included when using
Spring MVC or any other framework for that matter. This gives you a container that may be used to configure other types of spring beans that provide support for things like data persistence. Basically, in this configuration file is where you pull in all of the other goodies Spring offers.
dispatcher-servlet.xml is a child context of applicationContext
ContextLoaderListener looks for
applicationContext.xml (or for the file specified by the context-param
contextConfigLocation. Again the path is relative to the context-root. I usually place mine in
/WEB-INF/classes/applicationContext.xml, and set this as a value of the context-param).
dispatcher-servlet.xml is a child context to the one defined by
applicationContext.xml. The child context can access beans from the parent context, but the opposite is not true. So imagine you have a “web” context, with all controllers and web-related stuff, and a “main” context with everything else
servlet-mapping / url-pattern: / vs /*
SRV.11.2 Specification of Mappings
In theWeb application deployment descriptor, the following syntax is used to define mappings:
* A string beginning with a / character and ending with a /* suffix is used for path mapping.
* A string beginning with a *. prefix is used as an extension mapping.
* A string containing only the / character indicates the “default” servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null.
* All other strings are used for exact matches only.
The pattern /* will force everything through your servlet.
The pattern / will make your servlet the default servlet for the app, meaning it will pick up every pattern that doesn’t have another exact match.
A good article on Common mistakes when using Spring MVC