How does SSM framework spring integrate SpringMVC and Mybatis (based on annotations)

How does SSM framework spring integrate SpringMVC and Mybatis (based on annotations)

The relationship between the three-tier architecture and the SSM architecture
Insert picture description here

Spring integration of SpringMVC and Mybatis diagram
Insert picture description here

Spring integration of SpringMVC and Mybatis steps

1、导入相关的依赖

2、创建数据库表和对应的实体类

3、分别创建表现层、业务层、持久层的类(表现层调用业务层方法、业务层调用持久层方法、
   持久层执行sql语句返回数据库信息,表现层得到信息执行相关操作)

4、web.xml配置三大组件--(加载Spring的配置文件)监听器、
   前端控制器(加载Springmvc的配置文件)、过滤器(解决中文乱码)

5、Spring的配置文件(applicationContext.xml)配置:
      开启注解的扫描(扫描service和dao注解)
      整合Mybatis框架(配置数据连接池、配置SqlSessionFactory工厂、
                     配置接口(dao)所在的包、配置事务管理(配置事务管理器、
                                            配置事务通知、配置aop增强))

6、SpringMVC的配置文件(springmvc.xml)配置:
      开启注解的扫描(扫描Controller注解)、视图解析器对象、
      静态资源(不拦截)、开启Springmvc对注解的支持

  (配置文件存放到resources里面)

7、创建注册页面、登录页面.....等JSP页面    
  (WEB-INF下存放的是用户不能访问的页面,如注册成功页面、登录成功页面、
   管理员页面...

Guess you like

Origin blog.csdn.net/weixin_49092628/article/details/110871016