把下面两个方法的代码改写如下:
public int getFirstIndexForCurrentPage() {
return (this.currentPage - 1) * this.pageSize;
}
/**
* Returns the index into the master list of the last object that should appear on the current page that the user is
* viewing.
* @return int
*/
protected int getLastIndexForCurrentPage() {
if (this.partialList) {
return (getFirstIndexForCurrentPage()) +
Math.min(this.pageSize - 1, this.fullList.size() - 1);
} else {
return getLastIndexForPage(this.currentPage);
}
}
本文介绍了如何优化org.displaytag.pagination.SmartListHelper.java中的分页功能。通过调整getFirstIndexForCurrentPage()和getLastIndexForCurrentPage()方法,实现更灵活的分页逻辑。适用于部分列表展示场景。
2746

被折叠的 条评论
为什么被折叠?



