mybatis使用条件分页查询
作者:互联网
@Override
public PageInfo<Student> findByCriteria(Integer stuno, String name) {
PageHelper.startPage(2,2);
StudentExample example = new StudentExample();
StudentExample.Criteria criteria = example.createCriteria();
//设置查询大于传入学号的数据
criteria.andStunoGreaterThan(stuno);
criteria.andNameLike("%"+name+"%");
Page<Student> students = (Page<Student>) studentMapper.selectByExample(example);
PageInfo<Student> pageInfo = new PageInfo<Student>(students);
return pageInfo;
}
对于pageInfo的使用不能直接将
studentMapper.selectByExample(example)强转为pageinfo而是要先从list类型转成page类型再将page类型转换成pageinfo类型
标签:分页,studentMapper,example,PageInfo,criteria,mybatis,查询,pageInfo,StudentExample 来源: https://blog.csdn.net/qq_44185887/article/details/123239996