流程圖:
1. 首先瀏覽器上訪問路徑 /listCategory
2. tomcat根據web.xml上的配置信息,攔截到了/listCategory,並將其交由DispatcherServlet處理。
3. DispatcherServlet 根據springMVC的配置,將這次請求交由CategoryController類進行處理,所以需要進行這個類的實例化
4. 在實例化CategoryController的時候,注入CategoryServiceImpl。 (自動裝配實現了CategoryService接口的的實例,只有CategoryServiceImpl實現了CategoryService接口,所以就會注入CategoryServiceImpl)
5. 在實例化CategoryServiceImpl的時候,又注入CategoryMapper
6. 根據ApplicationContext.xml中的配置信息,將CategoryMapper和Category.xml關聯起來了。
7. 這樣拿到了實例化好了的CategoryController,並調用 list 方法
8. 在list方法中,訪問CategoryService,並獲取數據,並把數據放在"cs"上,接着服務端跳轉到listCategory.jsp去
9. 最后在listCategory.jsp 中顯示數據
流程圖: