bootstrap分页
来源:互联网 发布:易语言web服务器源码 编辑:程序博客网 时间:2024/05/16 23:48
实现下图:
jsp:
function initTable() { //先销毁表格 $('#MenuTable').bootstrapTable('destroy'); //初始化表格,动态从服务器加载数据 $('#MenuTable').bootstrapTable({ method: "get", //使用get请求到服务器获取数据 // method: "post", //contentType: "application/x-www-form-urlencoded", url: 'wxgl/follower/wxfollowerList.do', //获取数据的Servlet地址 //toolbar: '#toolbar', striped: true, //表格显示条纹 pagination: true, //启动分页 pageSize: 10, //每页显示的记录数 pageNumber:1, //当前第几页 pageList: [10, 15, 20, 25], //记录数可选列表 smartDisplay: false,//智能显示分页按钮 paginationPreText: "上一页", paginationNextText: "下一页", search: false, //是否启用查询 //showColumns: true, //显示下拉框勾选要显示的列 // showRefresh: true, //显示刷新按钮 sidePagination: "server", //表示服务端请求 //设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder //设置为limit可以获取limit, offset, search, sort, order queryParamsType : "undefined", queryParams: function queryParams(params) { //设置查询参数 var param = { pageNumber: params.pageNumber, pageSize: params.pageSize, orderNum : $("#orderNum").val() }; console.log(param); return param; }, columns: [{ checkbox: true },{ field: 'OPENID', title:'关注人ID ', width:200 },{ field: 'NICKNAME', title:'昵称', width:150 },{ field: 'SEX', title:'性别', width:30 },{ field: 'COUNTRY', title:'国籍', width:100 },{ field: 'SUBSCRIBE_TIME', title:'关注时间', align: 'center', valign: 'middle', width:150 }], onLoadSuccess: function(data){ //加载成功时执行 // alert("加载成功"); }, onLoadError: function(){ //加载失败时执行 alert("加载数据失败", {time : 1500, icon : 2}); } }); }
控制层:注意MAP里的值
public void queryMenuList(HttpServletResponse response,HttpServletRequest request,String NICKNAME) throws IOException{ List<FollowerMessage> rows = null; //需要传入微信ID HttpSession session=request.getSession(); wxid=(String)session.getAttribute(Const.WB_wxId); SysUser sysUser=(SysUser)session.getAttribute(Const.WBUSER_SESSION); userid=sysUser.getUserId(); int pageSize = Integer.parseInt(request.getParameter("pageSize")); int pageNumber = Integer.parseInt(request.getParameter("pageNumber")); int start = (pageNumber-1)*pageSize; int end = pageNumber*pageSize; Map map = new HashMap(); map.put("wxid", wxid); map.put("start", start); map.put("end", end); map.put("NICKNAME", NICKNAME); rows = wxFollowerService.getFollower(map); int total=wxFollowerService.countFollower(map); Map<String, Object> jsonMap = new HashMap<String, Object>();// 定义map jsonMap.put("rows", rows);// rows键 存放每页记录 list jsonMap.put("total", total);// total键 存放总记录数,必须的 //JSONArray result=JSONArray.fromObject(jsonMap); JSONObject result = JSONObject.fromObject(jsonMap);// 格式化result //logger.info(result); // 一定要是JSONObject response.setContentType("text/html;charset=utf-8"); PrintWriter writer = response.getWriter(); writer.write(result.toString()); writer.flush();}
mybatis:
<select id="getFollower" resultType="com.htxx.wxgl.entity.FollowerMessage" parameterType="map"> select * from( select a.* ,ROWNUM rn from ( SELECT OPENID,NICKNAME,COUNTRY,SUBSCRIBE_TIME, (CASE WHEN SEX='1' THEN '男' WHEN SEX='2' THEN '女' ELSE '未知' END) AS SEX from wechat_user WHERE WID=#{wxid} AND ZT='1' <if test=" NICKNAME!=null and NICKNAME!='' "> and NICKNAME like '%${NICKNAME}%' </if> ) a where ROWNUM <= #{end} ) where rn > #{start} </select> <select id="countFollower" resultType="int" parameterType="map"> select count(*) from wechat_user WHERE WID=#{wxid} AND ZT='1' <if test="NICKNAME !=null and NICKNAME !='' "> and NICKNAME like '%${NICKNAME}%'</if></select>
0 0
- bootstrap分页
- bootstrap分页
- Bootstrap 分页
- bootstrap分页
- Bootstrap 分页
- bootstrap-分页
- bootstrap 分页
- bootstrap分页
- BootStrap 分页
- bootstrap分页
- Bootstrap分页
- bootstrap 分页
- Bootstrap分页插件--Bootstrap Paginator
- Bootstrap分页插件--Bootstrap Paginator
- bootstrap分页插件Bootstrap Paginator
- Bootstrap分页插件--Bootstrap Paginator
- bootstrap table 分页,客户端分页
- bootstrap分页样式
- oracle 常见函数
- H5游戏颠覆手游的想象
- android 调用系统相册选取照片或者打开相机拍照获取图片,返回时回到手机桌面,然后才会跳转到当前activity
- Longest Word in Dictionary through Deleting
- Log4j学习总结-2
- bootstrap分页
- Log4j学习总结-3
- selenium从安装到使用
- Android Xposed框架 -- 开发篇
- Mac下安装MongoDB
- 关于Android里EditText控件getText()返回值问题
- Spring Cache编写实例
- Spring注解原理学习(自己编写例子)-2
- ELK中logstash下的grok正则表达式总结