Search in sources :

Example 1 with TbItemMapper

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());
}
Also used : PageInfo(com.github.pagehelper.PageInfo) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) TbItemMapper(cn.e3mall.manager.dao.TbItemMapper) TbItem(cn.e3mall.manager.pojo.TbItem) Test(org.junit.Test)

Aggregations

TbItemMapper (cn.e3mall.manager.dao.TbItemMapper)1 TbItem (cn.e3mall.manager.pojo.TbItem)1 PageInfo (com.github.pagehelper.PageInfo)1 Test (org.junit.Test)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1