bootstrap-table 前端分页
既然有那么好的轮子 ,为什么要重复造轮子。
Html页面
<!doctype html> <html xmlns:th="http://www.thymeleaf.org"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Hello, Bootstrap Table!</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous"> <link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.16.0/dist/bootstrap-table.min.css"> <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <script src="https://unpkg.com/bootstrap-table@1.16.0/dist/bootstrap-table.min.js"></script> <link href="https://unpkg.com/bootstrap-table@1.16.0/dist/bootstrap-table.min.css" rel="stylesheet"> <!-- 引入语言包 --> <script src="https://unpkg.com/bootstrap-table@1.16.0/dist/bootstrap-table-locale-all.min.js"></script> </head> <body> <h2>前端分页</h2> <table id="table_server" ></table> <script> $(function (){ $("#table_server").bootstrapTable({ url:"http://localhost:8080/user/list", //请求地址 striped : true, //是否显示行间隔色 pageNumber : 1, //初始化加载第一页 pagination : true,//是否分页 sidePagination : 'client',//server:服务器端分页|client:前端分页 pageSize : 5,//单页记录数 search:true,//搜索 locale :'zh-CN',//设置成中文 showColumns: true, showToggle:true,//改变表格展示样式 pageList : [ 5, 10],//可选择单页记录数 showRefresh : true,//刷新按钮 sortable: true, // 是否启用排序 columns : [ { title : 'id', field : 'id', sortable : true }, { title : '姓名', field : 'title', sortable : true }, { title : '年龄', field : 'summary', sortable : true },{ title : '性别', field : 'cover_img', sortable : true }] }) }) </script> </body> </html>
后端controller
@RequestMapping(value = "/list") @ResponseBody public Object list(HttpServletRequest request){ //PageHelper.startPage(0, 10); // request.setAttribute("test", test.findAllStudent()); return test.findAllStudent(); }
效果:
参考链接
bootstrap-table官方:https://examples.bootstrap-table.com/
其他大神的参考地址:
大神一:https://www.cnblogs.com/wl1202/p/10677196.html
大神二:https://www.jianshu.com/p/761299fd877f
本文作者:KwFruit
本文链接:https://www.cnblogs.com/mangoubiubiu/p/12906377.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)