use of cn.e3mall.manager.dao.TbItemMapper in project e3mall by colg-cloud.
the class PageHelperTest method testPageHelper.
@Test
public void testPageHelper() {
applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext-dao.xml");
// 从容器中获得Mapper代理对象
TbItemMapper tbItemMapper = applicationContext.getBean(TbItemMapper.class);
// 执行sql语句之前设置分页信息,使用PageHelper的startPatge方法
PageHelper.startPage(1, 10);
// 执行查询
List<TbItem> list = tbItemMapper.selectAll();
// 取分页信息,PageInfo,1:总记录数,2:总页数,当前页码
PageInfo<TbItem> pageInfo = new PageInfo<>(list);
System.out.println(pageInfo.getTotal());
System.out.println(pageInfo.getPages());
System.out.println(list.size());
}
Aggregations