一:ContextLoaderListener加載內容
二:DispatcherServlt加載內容
ContextLoaderListener和DispatcherServlet都會在Web容器啓動的時候加載一下bean配置. 區別在於:
DispatcherServlet一般會加載MVC相關的bean配置管理(如: ViewResolver, Controller, MultipartResolver, ExceptionHandler, etc.)
ContextLoaderListener一般會加載整個Spring容器相關的bean配置管理(如: Log, Service, Dao, PropertiesLoader, etc.)
DispatcherServlet默認使用WebApplicationContext作爲上下文.
值得注意的是, DispatcherServlet的上下文僅僅是Spring MVC的上下文, 而ContextLoaderListener的上下文則對整個Spring都有效. 一般Spring web項目中同時會使用這兩種上下文.