1.applicationcontext.xml is a spring global configuration file that controls the spring features
2.dispatcher-servlet.xml is a spring MVC inside, controller, intercept URI forwarding view
3. If a bean is defined in two files (for example, two files define the same package as component scan), Spring generates an instance in both application context and servlet context. They are in different contexts, and they may behave differently.
4. If there is an instance of the same @Service in both the application context and the servlet context, the controller (in servlet context) passes the @Resource reference, The instance in the servlet context is selected first.
5. According to the website interpretation servlet context can refer to application context instances, and vice versa.
6. Multiple servlets sharing instances in application context
7. Recommended method: Servlet only scans @controler; Application Scan Other
Servlet.xml Scan Configuration
<!--The annotations in the scan package to generate the bean-->
<context:component-scan base-package= " Com.ssm.controller "use-default-filters=" false "
<context: Include-filter type= "Annotation"
expression= " Org.springframework.stereotype.Controller "/>
</context:component-scan
<context:component-scan base-package= "COM.SSM" use-default-filters= "true" >
<context:exclude-filter type= "Annotation"
expression= "Org.springframework.stereotype.Controller"/>
</context:component-scan>
The difference between Applicationcontext-xxx.xml and Xxx-servlet.xml