package cn.pdsu; /** * 开始页,结束页封装 * * @author 作者:user * @version 创建时间:2011-7-19 上午03:08:25 */ public class PageIndex { /** * 结束页 */ private int endIndex; /** * 开始页 */ private int startIndex; /** * 计算开始页和结束页 * * @param viewpagecount * 页面中要显示的页面个数 * @param currentPage * 当前页 * @param totalpage * 总页面数 * @return PageIndex 记录开始页(startindex)和结束页(endindex) */ public static PageIndex getPageIndex(int viewpagecount, int currentPage, int totalpage) { int startpage = currentPage - (viewpagecount % 2 == 0 ? viewpagecount / 2 - 1 : viewpagecount / 2); int endpage = currentPage + viewpagecount / 2; if (startpage < 1) { startpage = 1; if (totalpage >= viewpagecount) endpage = viewpagecount; else endpage = totalpage; } if (endpage > totalpage) { endpage = totalpage; if ((endpage - viewpagecount) > 0) startpage = endpage - viewpagecount + 1; else startpage = 1; } return new PageIndex(startpage, endpage); } public PageIndex(int startIndex, int endIndex) { this.startIndex = startIndex; this.endIndex = endIndex; } public int getEndIndex() { return endIndex; } public void setEndIndex(int endIndex) { this.endIndex = endIndex; } public int getStartIndex() { return startIndex; } public void setStartIndex(int startIndex) { this.startIndex = startIndex; } }

taoshen95 LV16
2024年12月16日
asddwh LV13
2023年12月29日
wuge123 LV8
2023年6月12日
1719863922 LV11
2022年6月17日
刚刚vv谭v LV4
2022年1月4日
微信网友_5768552477921280 LV6
2022年1月2日
17771013609 LV4
2021年12月31日
fesdfs LV1
2021年12月20日
3089559272 LV11
2021年12月17日
龙门客栈 LV9
2021年12月16日

taoshen95 LV16
2024年12月16日
时光海 LV2
2024年7月1日
liyan54188 LV2
2024年6月25日
sdaijdiafafon
2024年6月23日
暂无贡献等级
沈从文 LV3
2023年12月31日
asddwh LV13
2023年12月25日
wodewode LV1
2023年12月23日
微信网友_6786215447367680 LV5
2023年12月23日
好哇好哇还是
2023年12月20日
暂无贡献等级
颜菜菜 LV2
2023年12月19日