springmvc(五)springmvc和mybatis整合
2016-01-10 18:53
561 查看
需求
使用springmvc和mybatis完成商品列表查询。
sqlMapConfig.xml
mybatis自己的配置文件。
applicationContext-dao.xml
手动定义商品查询mapper
针对综合查询mapper,一般情况会有关联查询,建议自定义mapper
ItemsQueryVo
ItemsCustom
ItemsMapperCustom.java
整合service
让spring管理service接口。
定义service接口
在spring容器配置service(applicationContext-service.xml)
创建applicationContext-service.xml,文件中配置service。
配置前端控制器
编写jsp
加载spring容器
将mapper、service、controller加载到spring容器中。
建议使用通配符加载上边的配置文件。
在web.xml中,添加spring容器监听器,加载spring容器。
使用springmvc和mybatis完成商品列表查询。
整合dao
mybatis和spring进行整合。sqlMapConfig.xml
mybatis自己的配置文件。
applicationContext-dao.xml
逆向工程生成po类及mapper(单表增删改查)
手动定义商品查询mapper
针对综合查询mapper,一般情况会有关联查询,建议自定义mapper
ItemsMapperCustom.xml
ItemsQueryVo
ItemsCustom
ItemsMapperCustom.java
整合service
让spring管理service接口。
定义service接口
在spring容器配置service(applicationContext-service.xml)
创建applicationContext-service.xml,文件中配置service。
事务控制(applicationContext-transaction.xml)
整合springmvc
springmvc.xml
创建springmvc.xml文件,配置处理器映射器、适配器、视图解析器。配置前端控制器
编写Controller(就是Handler)
编写jsp
加载spring容器
将mapper、service、controller加载到spring容器中。
建议使用通配符加载上边的配置文件。
在web.xml中,添加spring容器监听器,加载spring容器。
相关文章推荐
- 使用java类库中的Observable类和Observer接口实现观察者模式(精简版)
- Java基础(二)——数组
- Eclipse快捷键大全(转载)
- java写一个死锁
- java中字符串的截取
- 简化Spring的XML配置(三)——自动寻找bean
- struts.xml框架
- 【spring配置】——spring管理事务(transaction)
- 关于浏览器不能执行JavaScrip问题的反思
- 【慕课笔记】第三章 常用的运算符 第5节 JAVA中的逻辑运算符
- 【慕课笔记】第三章 常用的运算符 第4节 JAVA中的比较运算符
- java找出2个集合相同和不同的元素(以及去除List中的重复元素)
- Java基础(一)——equals和==的区别
- [Java]例解Interface
- 第五章 Java运算符
- Java学习笔记: 泛型
- Spring MVC视图问题
- JNI的native代码中打印日志到eclipse的logcat中
- 如何计算Java对象占用了多少空间?
- Java深度历险(二)——Java类的加载、链接和初始化