web項目的拆法:
根據什麼來拆分?
i.MCV模式
UI(html/css/jsp,Servlet) applicationController.xml
Service:applicationService.xml
Dao:applicationDao.xml
公共數據庫:applicationDB.xml
ii.功能結構
學生相關配置:applicationContextStudent.xml
班級相關配置:applicationContextClass.xml
合併:如何 將多個配置文件合併
在web.xml文件中配置:
<context-param>
<!--監聽器的父類,中有一個contextConfigLocation,該屬性值保持着容
器配置文件applicationContext.xml的位置 -->
<param-name>contextConfigLocation</param-name>
<param-value>classpath:*.xml</param-value>
這樣就可以批量加載配置文件,也可以在初始化時加載配置文件,推薦使用這種:
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 配置springMVC需要加載的配置文件
spring-dao.xml,spring-service.xml,spring-mvc.xml
Mybatis - > spring -> springmvc
-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-*.xml</param-value>
</init-param>
</servlet>