SpringMVC注解相關

1、web容器在啟動的時候,會掃描每個jar包下的META-INF/services/javax.servlet.ServletContainerInitializer
2、加載這個文件指定的類SpringServletContainerInitializer
3、spring的應用一啟動會加載感興趣的WebApplicationInitializer接口的下的所有組件;
4、并且為WebApplicationInitializer組件創(chuàng)建對象(組件不是接口,不是抽象類)
1)、AbstractContextLoaderInitializer:創(chuàng)建根容器;createRootApplicationContext();
2)、AbstractDispatcherServletInitializer:
創(chuàng)建一個web的ioc容器;createServletApplicationContext();
創(chuàng)建了DispatcherServlet;createDispatcherServlet();
將創(chuàng)建的DispatcherServlet添加到ServletContext中;
getServletMappings();
3)、AbstractAnnotationConfigDispatcherServletInitializer:注解方式配置的DispatcherServlet初始化器
創(chuàng)建根容器:createRootApplicationContext()
getRootConfigClasses();傳入一個配置類
創(chuàng)建web的ioc容器: createServletApplicationContext();
獲取配置類;getServletConfigClasses();

總結:
以注解方式來啟動SpringMVC;繼承AbstractAnnotationConfigDispatcherServletInitializer;
實現(xiàn)抽象方法指定DispatcherServlet的配置信息;

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容