说明
bootstrap table可以前端分页,也可以后端sql用limit分页。
前端分页下性能和意义都不大,故一般情况下不用这种,请看我的另一篇后端分页的博客
源码下载地址:https://git.oschina.net/dshvv/pagination_byjs.git
该文主要讲前端分页:
1、后端一次性查询所,(底层因该是有个缓存json)然后前端分页
2、查询也是前端搜索(即搜索前端缓存的json内容),不进入服务器

源码

html

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<meta charset="utf-8">
<title>图片上传</title>
<!-- jq -->
<script type="text/javascript" src="<%=basePath%>js/jquery-3.1.1.min.js"></script> <!-- bootstrap -->
<link rel="stylesheet" href="<%=basePath%>/plugs/bootstrap/css/bootstrap.min.css">
<script type="text/javascript" src="<%=basePath%>/plugs/bootstrap/js/bootstrap.min.js"></script> <!-- 分页插件 -->
<link rel="stylesheet" href="<%=basePath%>plugs/bootstrap-table/bootstrap-table.min.css">
<script type="text/javascript" src="<%=basePath%>plugs/bootstrap-table/bootstrap-table.min.js"></script>
<script type="text/javascript" src="<%=basePath%>plugs/bootstrap-table/bootstrap-table-locale-all.min.js"></script>
</head>
<body>
<div class="container" style="margin-top:100px">
<div class="row">
<!-- 表格 -->
<div class="col-xs-12">
<table class="table table-striped table-bordered table-hover" ></table>
</div>
</div>
</div>
<script type="text/javascript">
class BstpTable{
constructor(obj) {
this.obj=obj;
}
inint(){
//---先销毁表格 ---
this.obj.bootstrapTable('destroy');
//---初始化表格,动态从服务器加载数据---
this.obj.bootstrapTable({
//【发出请求的基础信息】
url: '<%=basePath%>student/selectAll',
method: 'post',
contentType: "application/x-www-form-urlencoded", //【其它设置】
locale:'zh-CN',//中文支持
pagination: true,//是否开启分页(*)
pageNumber:1,//初始化加载第一页,默认第一页
pageSize: 3,//每页的记录行数(*)
pageList: [2,3,4],//可供选择的每页的行数(*)
sidePagination: "client", //分页方式:client客户端分页,server服务端分页(*)
showRefresh:true,//刷新按钮
search: true,//是否显示表格搜索,此搜索是客户端搜索,不会进服务端 //【样式设置】
height: 300,//table的高度
//按需求设置不同的样式:5个取值代表5中颜色['active', 'success', 'info', 'warning', 'danger'];
rowStyle: function (row, index) {
var style = "";
if (row.name=="毛主席") {style ='danger';}
return { classes: style }
}, //【设置列】
columns: [
{field: 'id',title: 'id'},
{field: 'name',title: '姓名'},
{field: 'age',title: '年龄'},
{field: 'tool',title: '操作', align: 'center',
formatter:function(value,row,index){
var element =
"<a class='edit' data-id='"+row.id +"'>编辑</a> "+
"<a class='delet' data-id='"+row.id +"'>删除</a> ";
return element;
}
}
]
})
}
} var bstpTable=new BstpTable($("table"));
bstpTable.inint()
</script>
</body>
</html>

controller

package com.dsh.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.dsh.pojo.Student;
import com.dsh.service.StudentService; @Controller
@RequestMapping("student")
public class StudentController {
@Autowired
private StudentService studentService; @RequestMapping("selectAll")
@ResponseBody
public List<Student> getAll(){
return studentService.selectAll();
}
}

service

package com.dsh.service.imp;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dsh.mapper.StudentMapper;
import com.dsh.pojo.Student;
import com.dsh.pojo.StudentExample;
import com.dsh.pojo.StudentExample.Criteria;
import com.dsh.service.StudentService; @Service
public class StudentServiceImp implements StudentService {
@Autowired
private StudentMapper studentMapper;
public List<Student> selectAll() {
//这里我用的是mybatis自定生成的代码里Example查询用法,不需理解,会用就行
StudentExample example=new StudentExample();
Criteria criteria=example.createCriteria();
criteria.getAllCriteria();
return studentMapper.selectByExample(example);
}
}

Bootstrap table前端分页(ssm版)的更多相关文章

  1. bootstrap table 服务器端分页例子分享

    这篇文章主要介绍了bootstrap table 服务器端分页例子分享,需要的朋友可以参考下 1,前台引入所需的js 可以从官网上下载 复制代码代码如下: function getTab(){var ...

  2. [转]Bootstrap table后端分页(ssm版)

    原文地址:https://www.cnblogs.com/flyins/p/6752285.html 说明bootstrap table可以前端分页,也可以后端sql用limit分页.这里讲的是后端分 ...

  3. Bootstrap table后端分页(ssm版)

    说明bootstrap table可以前端分页,也可以后端sql用limit分页.这里讲的是后端分页,即实用limit.性能较好,一般均用这种源码下载地址:https://git.oschina.ne ...

  4. [前端插件]Bootstrap Table服务器分页与在线编辑应用总结

    先看Bootstrap Table应用效果: 表格用来显示数据库中的数据,数据通过AJAX从服务器加载,同时分页功能有服务器实现,避免客户端分页,在加载大量数据时造成的用户体验不好.还可以设置查询数据 ...

  5. 161222、Bootstrap table 服务器端分页示例

    bootstrap版本 为 3.X bootstrap-table.min.css bootstrap-table-zh-CN.min.js bootstrap-table.min.js 前端boot ...

  6. C# Bootstrap table之 分页

    效果如图: 一.声明talbe <div class="container"> <table id="table" class="t ...

  7. bootstrap table 前端搜索

    1.bootstrap-table对于前端的搜索可以通过官网设置,但发现前端搜索出现bug,网上找到一个bootstrap-table的扩充js  bootstrap-table-mytoolbar. ...

  8. [转]C# Bootstrap table之 分页

    本文转自:https://www.cnblogs.com/zhangjd/p/7895453.html 效果如图: 一.声明talbe <div class="container&qu ...

  9. bootstrap table 服务器端分页--ashx+ajax

    1.准备静态页面 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-T ...

随机推荐

  1. TestNG入门教程

    阅读目录 TestNG介绍 在Eclipse中在线安装TestNG 在Eclipse中离线安装Testng TestNG最简单的测试 TestNG的基本注解 TestNG中如何执行测试 使用testt ...

  2. InstallShield程序打包图解

    InstallShield程序打包图解     VS2012中打包工具被看做程序集,在使用时和程序集一样被创建到程序解决方案下.需要我们做的是添加项目即可.但是对于初次使用的朋友来说,我们需要根据提示 ...

  3. js里面声明变量时候的注意事项

    变量名可以是中文,只能有下划线,$,数字和字母组成,开头只能以下划线(不建议使用)和字母开头.

  4. Jquery checkbox选中问题

    checkbox中有.checked的写法,判断当前是否是选中状态,不过这种是针对[object HTMLInputElement]这种类型的,而对于[object Object]这种类型是不能使用的 ...

  5. ruby+gem常用命令

    gem是一种文件组织的包,一般的ruby的很多插件都有由这种各种的包提供.我们来看看gem的用法     ruby -v #查看ruby 版本 ruby -e ''require"watir ...

  6. TextureMerger1.6.6 三:Bitmap Font的制作和使用

    BitmapFont主要用于特殊字体在游戏中的使用. 比如我想使用方正剪纸字体,但是没加载方正剪纸.ttf字体时,egret是没法使用这种字体的. 或者美工制作了效果拔群的0123456789数字字体 ...

  7. 【BZOJ1594】[Usaco2008 Jan]猜数游戏 二分答案+并查集

    [BZOJ1594][Usaco2008 Jan]猜数游戏 Description 为了提高自己低得可怜的智商,奶牛们设计了一个新的猜数游戏,来锻炼她们的逻辑推理能力. 游戏开始前,一头指定的奶牛会在 ...

  8. Hive桶列BucketedTables

    The CLUSTERED BY and SORTED BY creation commands do not affect how data is inserted into a table – o ...

  9. linux .zip 解压命令集

    zip: 压缩: zip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][-b <工作目录>][-ll][-n <字尾字符串>][-t <日期时间>] ...

  10. loadrunner多场景的串行执行以及定时执行

    方法一: 既然是脚本串行执行,那在场景设计中必然是要用多个脚本,要注意的是需要将Scenario Schedule中的Schedule by设置为Group的模式.然后按实际需要依次设置每个脚本的Sc ...