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>