(1) 通过map,将page 放入map 中。拦截器中通过delegate.boundSql.parameterObject.page取。启动缓存时失效。需要拦截Executor 的query 重写CacheKey.
(2)重写RowBounds,拦截器中通过delegate.rowBounds取。当然可以在ReRowBounds 中添加分页方法。这样的话,利用RowBounds的offset、limit的值改变。不需要重写CacheKey。
public class ReRowBounds extends RowBounds
{
private Page page = new Page();
public ReRowBounds() {
super();
// TODO Auto-generated constructor stub
}
public ReRowBounds(int offset, int limit) {
super(offset, limit);
// TODO Auto-generated constructor stub
}
public Page getPage() {
return page;
}
}
List<Post> selectForPage(RowBounds rowBounds);
List<Post> selectByUserIDPage(Map map);