springxian

分页查询对比正常的查询差别不大,只是在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();
    }

 

分类:

技术点:

相关文章:

  • 2021-04-30
  • 2021-07-06
  • 2021-11-19
  • 2021-11-19
  • 2021-11-19
  • 2021-12-23
  • 2021-11-19
  • 2021-04-21
猜你喜欢
  • 2021-11-13
  • 2021-04-17
  • 2021-11-19
  • 2021-11-19
  • 2021-12-22
  • 2021-11-19
  • 2021-09-05
相关资源
相似解决方案