ibatis自带函数:
PaginatedList paginatedList
=sqlMap
.queryForPaginatedList(statementName, parameterObject, pageSize);
基于Spring框架来实现的分页
public
List getAllList(String flag)
{
PaginatedList paginatedList = this.getSqlMapClientTemplate().queryForPaginatedList("getAllList",null,5);
if ("privious".equals(flag))
{
paginatedList.previousPage();
}
else if ("next".equals(flag))
{
paginatedList.nextPage();
}
return paginatedList;
}
{
PaginatedList paginatedList = this.getSqlMapClientTemplate().queryForPaginatedList("getAllList",null,5);
if ("privious".equals(flag))
{
paginatedList.previousPage();
}
else if ("next".equals(flag))
{
paginatedList.nextPage();
}
return paginatedList;
}
在JSP中,如下调用:
<
button
onclick
="location.href = 'test.shtml?flag=privious'"
>
上一页
</
button
>
< button onclick ="location.href = 'test.shtml?flag=next'" > 下一页 </ button >
< button onclick ="location.href = 'test.shtml?flag=next'" > 下一页 </ button >
PS:此方法只可以用于小数量的数据查询,大数量此法不可行,速度慢的无法忍受。