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