第
springboot实现分页功能的完整代码
目录1.分页功能的作用2.建立测试数据库3.分页功能返回的结果封装4.分页功能代码具体实现4.1数据层4.2业务层4.3控制层5.jqGrid分页插件总结
1.分页功能的作用
分页功能作为各类网站和系统不可或缺的部分(例如百度搜索结果的分页等),当一个页面数据量大的时候分页作用就体现出来的,其作用有以下5个。
(1)减少系统资源的消耗
(2)提高数据库的查询性能
(3)提升页面的访问速度
(4)符合用户的浏览习惯
(5)适配页面的排版
2.建立测试数据库
由于需要实现分页功能,所需的数据较多
DROPTABLEIFEXISTStb_user;
CREATETABLEtb_user(
idint(11)NOTNULLAUTO_INCREMENTCOMMENT主键id,
namevarchar(100)NOTNULLDEFAULTCOMMENT登录名,
passwordvarchar(100)NOTNULLDEFAULTCOMMENT密码,
PRIMARYKEY(id)USINGBTREE
)ENGINE=InnoDBCHARACTERSET=utf8;
insertintotb_user(id,name,password)
value(1,C,123456),
(2,C++,123456),
(3,Java,123456),
(4,Python,123456),
(5,R,123456),
(6,C#,123456);
insertintotb_user(id,name,password)value(7,test1,123456);
insertintotb_user(id,name,password)value(8,test2,123456);
insertintotb_user(id,name,password)value(9,test3,123456);
insertintotb_user(id,name,password)value(10,test4,123456);
insertintotb_user(id,name,password)value(11,test5,123456);
insertintotb_user(id,name,password)value(12,test6,123456);
insertintotb_user(id,name,password)value(13,test7,123456);
insertintotb_user(id,name,password)value(14,test8,123456);
insertintotb_user(id,name,password)value(15,test9,123456);
insertintotb_user(id,name,password)value(16,test10,123456);
insertintotb_user(id,name,password)value(17,test11,123456);
insertintotb_user(id,name,password)value(18,test12,123456);
insertintotb_user(id,name,password)value(19,test13,123456);
insertintotb_user(id,name,password)value(20,test14,123456);
insertintotb_user(id,name,password)value(21,test15,123456);
insertintotb_user(id,name,password)value(22,test16,123456);
insertintotb_user(id,name,password)value(23,test17,123456);
insertintotb_user(id,name,password)value(24,test18,123456);
insertintotb_user(id,name,password)value(25,test19,123456);
insertintotb_user(id,name,password)valu