SSM整合---SpringMVC、Spring、MyBatis三个框架的整合步骤

SSM整合—SpringMVC、Spring、MyBatis三个框架的整合

整合分为三层结构:控制层(Controller层)—业务层(Service层)—持久层(Dao层)

三层结构的思路:

  1. 代码目录:
    控制层 controller:SpringMVC的后端控制器Controller–@Controller注解修饰的类,其中的方法用@RequestMapping修饰。
    业务层 service:业务的接口和实现类—实现类用@Service注解修饰的类
    持久层 dao:dao的接口和MyBatis映射文件—MyBatis动态代理包扫描 pojo:java bean

  2. 配置目录: config: SpringMVC.xml
    注解扫描(扫描的是@Controller注解)、注解驱动(当前版本下最新的注解形式的处理器映射器和处理器适配器)、视图解析器(可能包含前缀和后缀)
    ApplicationContext-service.xml
    注解扫描(扫描的是@Service注解)、事务管理(切面方式,切的是service目录,控制事务传播)
    ApplicationContext-dao.xml
    属性文件加载(可选)、数据源及连接池、MyBatis会话工厂、MyBatis动态代理包扫描
    MyBatisConfig.xml 空配置(预留,为了今后好扩展)
    其他的属性文件:jdbc.properties、log4j.properties。。。

  3. web.xml spring的监听器 SpringMVC的前端控制器 解决post乱码的filter

  4. 前端 视图:jsp—WEB-INF/jsp/***/*.jsp
    静态资源文件:WebContent/js/…、WebContent/css/…

猜你喜欢

转载自blog.csdn.net/qq_32332777/article/details/79044599