步骤:
1.在pom.xml添加依赖:
com.github.pagehelper pagehelper5.1.2
2.在applicationConfig.xml文件
a]加载数据源的地方添加:
mysql false
b.对service进行注册
3.写实体类,定义对象属性(属性名最好与数据库表字段一致,与数据库表不一致使用结果集映射ResultMap)
4.在Mapper.xml文件下对数据库进行操作
比如:
select * from 表名
易错点:数据库语句在此不能加上分号,个人理解为pageHelper自动给数据库语句加上分页功能处理。如不使用pageHelper,MySQL语句为:select * from 表名 limit ageNum,pageSize。
5.在service添加:
PageHelper.startPage(pageNum, pageSize);
6.在controller 调用service方法
比如:`
@RequestMapping("/getActList.do")
private List getActList(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "4") int pageSize){
List activities = activityService.getActList(pageNum,pageSize);
return activities;
}
`



