ContextLoaderListener和Spring MVC中的DispatcherServlet加載內容的區別


一: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項目中同時會使用這兩種上下文. 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM