在前端layui中,必须打开page属性才能导入依赖关系! --- page helper---- dependencygroupidcom.github.page helper/groupidartifactidpagehelper-spring-boot-starter /
limit:8是每页必须显示的条数
//表table.render(Elem:'#test ',URL : ' http://localhost 33608080/data ', toolbar : ' # toolbar demo '/toolbar如果不需要定制,删除此参数即可获得title: '提示',layEvent: 'LAYTABLE_TIPS ',lay table title3360 '用户数据表',cols:[{type:'checkbox ',fixed:'left'},{field:'id ',title3360'id {field:'lastName ',title: '用户名',width:120,},{field:'email ', title3360 '邮箱' templet3360function(RES ) { return 'em' res.email '/em' }},{field:'gender ',title 3360 } field :’department.department name’,title :’部门’,width:100,templet 3360 function { department },{ fiet } align :’center’,templet:function(d ) { return show time (d.b birth ) },{ fixed :’right’,title: 后端代码layui请求后端数据时,会携带俩个参数。一个是当前页,一个是页面显示的条数,是默认的,不用写代码
分页插件我们使用pageHelper
这三行代码是分页的方法主体中的两个参数由上述参数传递的,我们直接接收就可以了: pagehelper.startpage(page,limit ); listemployeeallist=employee mapper.get all (; pageinfoemployeepageinfo=new page info (allist,limit ); @ response body @ request mapping (/data ) ) publicJSONobjectlist1) intpage,int limit ) { //System.out.println )氟利昂listemployeeallist=employee mapper.get all (; pageinfoemployeepageinfo=new page info (allist,limit ); system.out.println(Allist; jsonobjectjsonobject=newjsonobject (; JSONobject.put('code ',0 ); Jonobject.put('msg ',1 ); Jonobject.put('count ',24 ); JSONobject.put('data ',allList ); 返回对象; } 效果图