MyBatis学习7之分页查询

阅读更多

(紧接着mybatsi学习6)分页查询使我们在做web开发中最常见的查询(本示例是在sqlite数据库中测试)

1、修改sql映射文件



 2、编写单元测试

public void testQuery3(){
		SqlSession session = null;
		try{
				session = sqlSessionFactory.openSession();
				String statement = "com.zlt.mybatis.vo.PersonInfoVo.pageQuery";
				//List persons = session.selectList(statement);
				Map map = new HashMap();
				map.put("pageNum", "1");
				map.put("pageSize", "2");
				List persons = session.selectList(statement,map);
				for(PersonInfoVo person : persons){
					if(null != person) {
						System.out.println("id:" + person.getId() + "\tuserName:" + person.getUserName() + "\tpassword:" + person.getPassword() + "\tpid:" + person.getPid() +"\tstate:" + person.getState());
					}
				}
			}finally{
			if(null != session) session.close();
		}
	}

 

你可能感兴趣的:(mybatis,分页)