bootstraptabl 销毁表格_基于SpringMVC+Bootstrap+DataTables实现表格服务端分页、模糊查询...

基于SpringMVC+Bootstrap+DataTables实现表格服务端分页、模糊查询

发布时间:2019-01-01 发布网站:编程之家

前言

基于SpringMVC+Bootstrap+DataTables实现数据表格服务端分页、模糊查询(非DataTables Search),页面异步刷新。

说明:sp:message标签是使用了SpringMVC国际化

效果

DataTable表格

关键字查询

自定义关键字查询,非DataTable Search

代码

HTML代码

查询条件代码

数据table代码

JS代码

DataTables初始化、服务端数据请求、查询条件封装

Java代码

Controller处理方法,负责查询页面需要表格数据,格式化Json后返回。

dataTable = goodsTypeService.getGoodsTypeByCondition(query);

dataTable.setDraw(query.getDraw());

String data = JSON.toJSONString(dataTable);

return data;

}

返回Json数据格式

DatatablesView,根据DataTables需要格式定义

{

private Listdata; //data 与datatales 加载的“dataSrc"对应

private int recordsTotal;

private int recordsFiltered;

private int draw;

public DatatablesView() {

}

public int getDraw() {

return draw;

}

public void setDraw(int draw) {

this.draw = draw;

}

public ListgetData() {

return data;

}

public void setData(Listdata) {

this.data = data;

}

public int getRecordsTotal() {

return recordsTotal;

}

public void setRecordsTotal(int recordsTotal) {

this.recordsTotal = recordsTotal;

this.recordsFiltered = recordsTotal;

}

public int getRecordsFiltered() {

return recordsFiltered;

}

public void setRecordsFiltered(int recordsFiltered) {

this.recordsFiltered = recordsFiltered;

}

}

Service业务处理类,主要根据查询条件统计记录数量,查询当前页数据列表

getGoodsTypeByCondition(QueryCondition query) {

DatatablesViewdataView = new DatatablesView();

//构建查询条件

WherePrams where = goodsTypeDao.structureConditon(query);

Long count = goodsTypeDao.count(where);

Listlist = goodsTypeDao.list(where);

dataView.setRecordsTotal(count.intValue());

dataView.setData(list);

return dataView;

}

Dao层就是基本的数据库查询操作,这里省略…

结尾

查询条件这里只使用了关键字模糊查询,根据业务需要,可以动态加入其他查询条件,后台需要做相应处理。

以上所述是小编给大家介绍的基于SpringMVC+Bootstrap+DataTables实现表格服务端分页、模糊查询,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值