mybatis 按照条件查询
@Autowired private StudentMapper studentMapper; @Override public Map getStudentList(int page, int rows,long studentId) { // 设置分页信息 PageHelper.startPage(page, rows); // 执行查询 StudentExample example = new StudentExample(); Criteria criteria = example.createCriteria(); //根据学生 id 查询 criteria.andStudentIdEqualTo(studentId);
//执行查询 List<Student> list = studentMapper.selectByExample(example);
// 取分页信息 PageInfo<TbContent> info = new PageInfo<>(list); Map map= new HashMap(); map.setRows(list); map.setTotal(info.getTotal()); return map; }