pagehelper 版本
https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter
在pom.xml中添加依赖
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.2</version>
</dependency>
不需要过多的配置,springboot中集成的基本都可以使用
前台easyui 传递分页参数
public Map<String,Object> queryShenPi(Integer page,Integer rows,ShenPiVo shenPiVo){
PageHelper.startPage(page,rows);
List<Psb> list = psbService.queryShenPi(shenPiVo);
System.out.println(shenPiVo);
System.out.println(list);
PageInfo<Psb> info = new PageInfo<>(list);
Map<String,Object> map = new HashMap<>();
//{"total":总记录数量,"rows": list集合}格式传递数据
map.put("total",info.getTotal());
map.put("rows",info.getList());
return map;
}
html页面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<script type="text/javascript" src="/js/jquery.js"></script>
<link rel="stylesheet" href="/js/easyui.css">
<link rel="stylesheet" href="/js/icon.css">
<script src="/js/jquery.easyui.min.js" ></script>
<script src="/js/easyui-lang-zh_CN.js"></script>
<body>
<div id="cc" class="easyui-layout" fit="true">
<div data-options="region:'center',title:'center title'" style="padding:5px;background:#eee;">
<table id="list" class="easyui-datagrid"></table>
</div>
</div>
</body>
<script>
$(function(){
intiTabs();
});
//转换日期格式
function changeDateFormat(value) {
var date = new Date(value);
var y = date.getFullYear();
var m = date.getMonth() + 1;
var d = date.getDate();
return y + '-' +m + '-' + d;
}
function intiTabs(){
$('#list').datagrid({
url:'/goods/queryList',
onLoadSuccess:function(data){
$(".updateBtn").linkbutton({text:'修改',plain:true,iconCls:'icon-edit'});
$(".infoBtn").linkbutton({text:'详情',plain:true,iconCls:'icon-search'});
$(".deleteBtn").linkbutton({text:'删除',plain:true,iconCls:'icon-no'});
},
columns:[[
{field:'goId',title:'商品ID',width:100,align:'center'},
{field:'goName',title:'商品名称',width:100,align:'center'},
{field:'goPrice',title:'商品价格',width:100,align:'center'},
{field:'goCount',title:'商品库存',width:100,align:'center'},
{field:'goDate',title:'上架时间',width:100,align:'center',
formatter: function(value,row,index){
return changeDateFormat(value);
}
},
{field:'dataBase',title:'操作',width:170,align:'center',
formatter: function(value,row,index){
var str="";
str+= "<a class='updateBtn' href='javascript:updateDialog()' class='easyui-linkbutton'>修改</a>";
str+= "<a class='infoBtn' href='javascript:queryFun()' class='easyui-linkbutton'>详情</a>";
str+= "<a class='deleteBtn' href='javascript:deleteFun()' class='easyui-linkbutton'>删除</a>";
return str;
}
}
]],
/* pagination 为true时 在 dataGrid底部显示分页工具 */
pagination:true,
/* 设置分页属性时初始化页面大小 */
pageSize:5,
/* 设置分页属性时,初始化页面大小的列表 */
pageList:[5,10,25,50,100],
fitColumns:true,
singleSelect:true,
});
}
</script>
</html>