SSM整合(一)

一.导jar包

1.spring包(spring4.2.4含springmvc)

2.mybatis包

3.mybatis-spring整合包

4.数据库驱动包(mysql)

5.第三方连接池(druid)

6.JSON依赖包(项目中用到)

 2.思路

 Dao层:

扫描二维码关注公众号,回复: 1848315 查看本文章

  1、SqlMapConfig.xml,空文件即可,但是需要文件头。

  2、applicationContext-dao.xml

    a)        数据库连接Druid

    b)        SqlSessionFactory对象,需要spring和mybatis整合包下的。

    c)        配置mapper文件扫描器。Mapper动态代理开发 增强版

Service层:

  1、applicationContext-service.xml包扫描器,扫描@service注解的类。

 

  2、applicationContext-trans.xml配置事务。

 Controller层:

  1、Springmvc.xml

  a)        包扫描器,扫描@Controller注解的类。

  b)        配置注解驱动

  c)        配置视图解析器

Web.xml文件:

  1、配置applicationContext配置文件和配置spring监听器

  2、配置过滤器,解决post乱码

  3、配置SpringMVC前端控制器

(参考黑马的视频和文档)

猜你喜欢

转载自www.cnblogs.com/black-fact/p/9257571.html
今日推荐