mybatis模糊查询/分页查询

模糊查询 like

        concat关键字

分页查询PageHelper

        sql分页查询语句

                select * from 表名  limit 0,5;

1,引入PageHelper依赖

 
            com.github.pagehelper
            pagehelper
            5.1.11
        

2,加入拦截


        
        
            
            
        
    

3,测试

  public class Testdao {
    private SqlSession session;
    @Before
    public void batis()throws Exception{
        Reader resourceAsReader = Resources.getResourceAsReader("batis.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(resourceAsReader);
        session = build.openSession();
    }
 @Test
    public void seecef()throws Exception{
//使用分页功能 request.getParamter("page")  request.getParamter("pageSize")
        BookIDao mapper = session.getMapper(BookIDao.class);
        PageHelper.startPage(1,20);
        Book book = new Book();
        book.setBookAuthor("曹");
        List selecttj = mapper.selecttj(book);
        //可以把查询的结果封装到PageInfo类中 包含你想要的任何信息
        PageInfo pageInfo = new PageInfo(selecttj);
        System.out.println("总条数"+pageInfo.getTotal());
        System.out.println("当前页数"+pageInfo.getPageNum());
        System.out.println("数据"+pageInfo.getList());
        System.out.println(selecttj);
    }
}

你可能感兴趣的:(linq,mariadb,elementui)