Mybatis--->limit分页查询


分页查询对比正常的查询差别不大,只是在sql语句上有区别

userMapper.class文件

//limit分页
List<User> limit(Map<String,Integer> map);

User mapper.xml 文件下映射对应文件

<select id="limit" parameterType="map" resultType="com.xian.pojo.User">
        select * from testdb.test001 limit #{index},#{end}
    </select>

test.class

@Test
    public void limit(){
        SqlSession sqlsession = MybatisUtils.getSqlsession();
        UserMapper mapper = sqlsession.getMapper(UserMapper.class);
        Map<String, Integer> map = new HashMap<String, Integer>();
        map.put("index",1);
        map.put("end",3);
        List<User> limit = mapper.limit(map);
        for (User user : limit) {
            System.out.println(user);
        }
        sqlsession.close();
    }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM