Java Mysql分页显示
2024-08-20 08:21:58
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; }
}
最新文章
- SpringMVC配置拦截器实现登录控制
- UWP中的Direct2D
- Docker之Web-UI
- Xlistview的values下的界面
- __LINE__ __DATE__ __FILE__ __TIME__ 等宏定义解释
- Android的所有权限说明
- 装黑苹果的那些事儿(以ThinkpadE540为例)
- Redis批量导入数据
- hdoj 5375 Gray Code
- 如何将excel文件中的数百万条数据在1分钟内导入数据库?
- NYOJ115 市叛乱 【SPFA】
- MVC生成CheckBoxList并对其验证
- testlink用例转换小工具(excel转为xml,python版)
- npm killed有可能是内存不够, 为Ubuntu增加swap
- eshint的配置
- laravel 项目表单中有csrf_token,但一直报错419错误 解决redis连接错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persi
- BZOJ4477[Jsoi2015]字符串树——可持久化trie树
- bzoj 2131 : 免费的馅饼 (树状数组优化dp)
- Vue2.0 新手完全填坑攻略—从环境搭建到发布
- REST easy with kbmMW #24 使用kbmMW实现JSON/XML/YAML转换成对象
热门文章
- 简述jpg。Gif。png-8.png-24的区别,分别使用场景
- Openstack+Kubernetes+Docker微服务实践之路--服务发布
- Ember.js 的视图层
- JS中判断 !=";"; 或者 !=null 失效
- fullpage 单屏高度超过屏幕高度,实现单屏内可以滚动并解决手机端单屏高度不正确的问题
- Android 防止OOM优化
- jQuery Mobile学习日记之HelloWorld
- 用excel做分组散点图
- Python’s SQLAlchemy vs Other ORMs[转发 0]
- JavaScript模块化