1、首先創建父容器(AnnotationConfigWebApplicationContext),透過自訂的getRootConfigClasses()拿到配置類,並註冊到父容器中。
2、透過父容器作爲參數創建ContextLoaderListener監聽器。並添加到servletContext(Tomcat servlet容器)。
3、透過自定的getServletConfigClasses()方法拿到MVC的配置類創建子容器,並把配置類註冊到子容器中。
4、創建DispatcherServlet,並將DispatcherServlet添加到servletContext的Servlet容器中去。
5、設定dispatcherServlet相關屬性(啓動時加載,設定映射路徑)。