当前位置:网站首页>分页工具类 pageUtil<T>
分页工具类 pageUtil<T>
2022-06-22 05:39:00 【小薛的BUG日志】
前言
在JavaWeb项目中,经常有需要分页查看的需求,那么创建一个分页工具类是很有必要的。此工具类将每页条数、当前页码、总记录数、总页数及当前页对应的数据列表集合起来,使用时在service层将这些数据获取并返回。
代码展示
/** * 分页实体类 * T:泛型 */
public class pageUtil<T> {
/* 1 页码;第几页 2 每页几 条 3 数据库总共多条【sql查询】 4 算总页数【算】 5 当前页的数据集合【sql查询】 */
private Integer pageIndex;
private Integer pageSize;
private Integer totalCount;//总共多条
private Integer totalPage;//总页数
private List<T> list;
public Integer getPageIndex() {
return pageIndex;
}
public void setPageIndex(Integer pageIndex) {
this.pageIndex = pageIndex;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount=totalCount;
}
public Integer getTotalPage() {
return totalPage;
}
public void setTotalPage() {
//计算总页码
this.totalPage=(this.totalCount%this.pageSize==0)?
this.totalCount/this.pageSize:
this.totalCount/this.pageSize+1;
}
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
}
边栏推荐
- Assertion based validation
- Market development trend forecast and investment risk outlook report of China's silicon carbide industry 2022-2027
- Xshell download and installation (solve the problem of expired evaluation)
- Market consumption survey and investment prospect forecast report of China's graphite industry 2022-2027
- AUTOSAR从入门到精通100讲(150)-SOA架构及应用
- 组合逻辑块的测试平台
- idea插件Easy Code的简单使用
- 401-字符串(344. 反转字符串、541. 反转字符串II、题目:剑指Offer 05.替换空格、151. 颠倒字符串中的单词)
- Introduction to golang Viper Library
- JTAG接口
猜你喜欢
随机推荐
PID notes
Unity 加密ASE 游戏数据
MFC tabctrl control to modify label size
GrabCut分析
Adaboost
Test platform for combinational logic blocks
W800芯片平台进入OpenHarmony主干
Analysis on the development status of China's copper aluminum composite bus industry and Research Report on investment opportunities 2022-2027
空调(春季每日一题 50)
System identification of automatic control principle
Using SystemVerilog to describe a state machine
Frame profiling
MFC TabCtrl 控件修改標簽尺寸
活动预告|EdgeX 开发者峰会@南京站 来啦!
Go language uses JWT
Server PHP related web page development environment construction
机器学习笔记 八:Octave实现神经网络的手写数字识别
串口(RS - 232)
Market survey and future production and marketing demand analysis report of China's zinc oxide nanoparticle industry 2022-2027
Machine learning Note 6: number recognition of multiple classification problems in logistic regression







