Bootstrap table前端分页(ssm版)



说明
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版)的更多相关文章
- bootstrap table 服务器端分页例子分享
这篇文章主要介绍了bootstrap table 服务器端分页例子分享,需要的朋友可以参考下 1,前台引入所需的js 可以从官网上下载 复制代码代码如下: function getTab(){var ...
- [转]Bootstrap table后端分页(ssm版)
原文地址:https://www.cnblogs.com/flyins/p/6752285.html 说明bootstrap table可以前端分页,也可以后端sql用limit分页.这里讲的是后端分 ...
- Bootstrap table后端分页(ssm版)
说明bootstrap table可以前端分页,也可以后端sql用limit分页.这里讲的是后端分页,即实用limit.性能较好,一般均用这种源码下载地址:https://git.oschina.ne ...
- [前端插件]Bootstrap Table服务器分页与在线编辑应用总结
先看Bootstrap Table应用效果: 表格用来显示数据库中的数据,数据通过AJAX从服务器加载,同时分页功能有服务器实现,避免客户端分页,在加载大量数据时造成的用户体验不好.还可以设置查询数据 ...
- 161222、Bootstrap table 服务器端分页示例
bootstrap版本 为 3.X bootstrap-table.min.css bootstrap-table-zh-CN.min.js bootstrap-table.min.js 前端boot ...
- C# Bootstrap table之 分页
效果如图: 一.声明talbe <div class="container"> <table id="table" class="t ...
- bootstrap table 前端搜索
1.bootstrap-table对于前端的搜索可以通过官网设置,但发现前端搜索出现bug,网上找到一个bootstrap-table的扩充js bootstrap-table-mytoolbar. ...
- [转]C# Bootstrap table之 分页
本文转自:https://www.cnblogs.com/zhangjd/p/7895453.html 效果如图: 一.声明talbe <div class="container&qu ...
- bootstrap table 服务器端分页--ashx+ajax
1.准备静态页面 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-T ...
随机推荐
- ios开发之--使用toolbar调整item之间的间隔
toolbar的item有很多种样式,其实经常使用的就几种, UIBarButtonSystemItemFixedSpace 木棍:可以理解为固定的长度 UIBarButtonSystemItemFl ...
- centos 安装 phalcon
git clone --depth 1 --branch phalcon-v2.0.3 https://github.com/phalcon/cphalcon.git cd cphalcon/ext ...
- UART简介
经常遇到初学者,对单片机串行通讯出了问题不知道如何办的情况.其实最有效的调试方法是用示波器观察收发数据的波形.通过观察波形可以确定以下情况: 1.数据是否接收或发送: 2.数据是否正确: 3.波特率是 ...
- lodash(一)数组
前言: lodash是一个具有一致接口.模块化.高性能等特性的JavaScript工具库(官网地址:http://lodashjs.com/docs/#_differencearray-values) ...
- nodejs 环境搭建
一 下载nodejs 官网:http://nodejs.cn/ 有时官网有点慢,可以去其他地方下载 统一下载站:http://www.3987.com/xiazai/2/43/57188.html 二 ...
- Mysql group_concat函数列转行,与行转列
例一: SELECT num from user 1.使用group_concat函数得到列转行 select group_concat(num) from user 2.使用SUBSTRING_IN ...
- IIS7的HTTP到HTTPS的重定向
方法一设置IIS 从HTTP到HTTPS的IIS7中的所有流量重定向,将确保用户始终安全地访问该网站.有许多不同的方法来设置一个IIS7从HTTP重定向到HTTPS和一些比别人更好.理想的HTTP到H ...
- java的Result类
import org.apache.commons.lang.StringUtils; import java.io.Serializable;import java.util.HashMap;imp ...
- web站点检查简易shell脚本
1.web样式 <h4>THE STATUS OF RS:</h4> <meta http-equiv="> <table border=" ...
- SpringMVC中 解决@ResponseBody注解返回中文乱码
问题:在前端通过get请求服务端返回String类型的服务时,会出现中文乱码问题 原因:由于spring默认对String类型的返回的编码采用的是 StringHttpMessageConverter ...