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; } }
最近下载更多
asddwh LV12
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日
电 LV5
2021年12月15日