1, paging

Consider: Why paging?

  • Reduce the amount of data to process

Paging with Limit

SELECT * FROM 'user' LIMIT startIndex,pageSize; # [0,3] SELECT * FROM 'user' LIMIT 3;

Use MyBatis to achieve paging, the core SQL 1. Interface

List<User> getUserByLimit(Map<String,Integer> Map);

2.Mapper.xml

<resultMap id="UserMap" type="User"> <! Column (column, column); > <result column="id" /> <result column="name" /> <result column=" PWD" property="password"/> </resultMap> <select id="getUserByLimit" parameterType="map" resultMap="UserMap"> select * from mybatis.user limit #{startIndex},#{pageSize} </select>

3. The test

@Test public void getUserByLimit(){ SqlSession sqlSession = MybatisUtils.getSqlSession(); UserMapper mapper = sqlSession.getMapper(UserDao.class); Map<String,Integer> map = new HashMap<>(); map.put("startIndex",0); map.put("pageSize",2); List<User> userList = mapper.getUserByLimit(map); for(User user:userList){ System.out.println(user); } // Close SQLSession.close (); }