mybatis 按照条件查询

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; }

 

posted @ 2018-03-18 14:23  方方方方方方  阅读(330)  评论(0编辑  收藏  举报