ContextLoaderListener和Spring MVC中的DispatcherServlet加载内容的区别

一:ContextLoaderListener加载内容web

  

二:DispatcherServlt加载内容spa

  

  ContextLoaderListener和DispatcherServlet都会在Web容器启动的时候加载一下bean配置. 区别在于:blog

  DispatcherServlet通常会加载MVC相关的bean配置管理(如: ViewResolver, Controller, MultipartResolver, ExceptionHandler, etc.)ip

  ContextLoaderListener通常会加载整个Spring容器相关的bean配置管理(如: Log, Service, Dao, PropertiesLoader, etc.)io

  DispatcherServlet默认使用WebApplicationContext做为上下文.容器

  值得注意的是, DispatcherServlet的上下文仅仅是Spring MVC的上下文, 而ContextLoaderListener的上下文则对整个Spring都有效. 通常Spring web项目中同时会使用这两种上下文. 配置

相关文章
相关标签/搜索