bootstrap-table配合pagehelper进行模糊查询

jsp页面,主要就是在option里面加个queryParams属性,这个属性是用于给后台传数据的,不写的时候默认传四个,自己可以外加俩,模糊查询input框的值,然后给点击模糊查询的时候加一个单击事件用来刷新这个table列表展现模糊查询出来的数据.

结合这一篇对比下  https://blog.csdn.net/kxj19980524/article/details/84678796

首先得在mybatis里配置pagehelper的插件



    
    
    
<%--
  Created by IntelliJ IDEA.
  User: liulx
  Date: 2018/9/3
  Time: 9:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>



    
    
    

    
    
    
    展示用户信息!




 

controller

//分页查询所有公司用户信息
@RequestMapping("/findAllUserManagerMsg")
@ResponseBody
public BootStrapResult findAllUserManagerMsg(BootTableParam param,String corporateName,String iphone){
    try {
        corporateName = new String(corporateName.getBytes("iso-8859-1"),"utf-8");  //这是防乱码
        iphone = new String(iphone.getBytes("iso-8859-1"),"utf-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    BootStrapResult result = witkeyUserService.findAllUserManagerMsg(param,corporateName,iphone);
    return  result;
}

service

@Override
public BootStrapResult findAllUserManagerMsg(BootTableParam param, String corporateName, String iphone) {
    PageHelper.offsetPage(param.getOffset(),param.getLimit());
    List allUserManagerMsg = witkeyUserMapper.findAllUserManagerMsg(param,corporateName,iphone);
    PageInfo info = new PageInfo<>(allUserManagerMsg);
    BootStrapResult result = new BootStrapResult();
    result.setTotal(info.getTotal());
    result.setRows(info.getList());
    return result;
}

mapper


接收参数的实体类

 

package com.bgs.pojo;

public class BootTableParam {
    private String sort;//排序的字段名 id
    private String order;//排序的方式:desc|asc
    private Integer offset;//偏移量,从第几条数据开始显示:0
    private Integer limit;//一页显示的条数:5

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public Integer getOffset() {
        return offset;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }
} 

返回参数的实体类

package com.bgs.pojo;

import java.util.List;

public class BootStrapResult {
    private Long total;//一共有多少条数据
    private List rows; //查询结果

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public List getRows() {
        return rows;
    }

    public void setRows(List rows) {
        this.rows = rows;
    }
}

你可能感兴趣的:(bootstarp)