public class View {
private int currentPage;
private int pageSize;
private int recordCount; public View(int pageSize, int recordCount, int currentPage) { this.pageSize = pageSize; this.recordCount = recordCount; this.setCurrentPage(currentPage); }
public int getPageCount() { int size = recordCount / pageSize; int flag = recordCount % pageSize; if (flag != 0) { size++; }
if (recordCount == 0) {
return 1; }
return size; } public int getFromIndex() { return (currentPage - 1) * pageSize; } public void setCurrentPage(int currentPage) { int vaildPage = currentPage <= 0 ? 1 : currentPage; vaildPage = vaildPage > this.getPageCount() ? this.getPageCount() : vaildPage; this.currentPage = vaildPage; } public int getCurrentPage() { return currentPage; } public int getPageSize() { return pageSize; }
}

最新文章

  1. SpringMVC配置拦截器实现登录控制
  2. UWP中的Direct2D
  3. Docker之Web-UI
  4. Xlistview的values下的界面
  5. __LINE__ __DATE__ __FILE__ __TIME__ 等宏定义解释
  6. Android的所有权限说明
  7. 装黑苹果的那些事儿(以ThinkpadE540为例)
  8. Redis批量导入数据
  9. hdoj 5375 Gray Code
  10. 如何将excel文件中的数百万条数据在1分钟内导入数据库?
  11. NYOJ115 市叛乱 【SPFA】
  12. MVC生成CheckBoxList并对其验证
  13. testlink用例转换小工具(excel转为xml,python版)
  14. npm killed有可能是内存不够, 为Ubuntu增加swap
  15. eshint的配置
  16. laravel 项目表单中有csrf_token,但一直报错419错误 解决redis连接错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persi
  17. BZOJ4477[Jsoi2015]字符串树——可持久化trie树
  18. bzoj 2131 : 免费的馅饼 (树状数组优化dp)
  19. Vue2.0 新手完全填坑攻略—从环境搭建到发布
  20. REST easy with kbmMW #24 使用kbmMW实现JSON/XML/YAML转换成对象

热门文章

  1. 简述jpg。Gif。png-8.png-24的区别,分别使用场景
  2. Openstack+Kubernetes+Docker微服务实践之路--服务发布
  3. Ember.js 的视图层
  4. JS中判断 !=&quot;&quot; 或者 !=null 失效
  5. fullpage 单屏高度超过屏幕高度,实现单屏内可以滚动并解决手机端单屏高度不正确的问题
  6. Android 防止OOM优化
  7. jQuery Mobile学习日记之HelloWorld
  8. 用excel做分组散点图
  9. Python’s SQLAlchemy vs Other ORMs[转发 0]
  10. JavaScript模块化