• MyBatis+springMVC+easyUI (dataGirl)实现分页


    页面展示效果。

    页面代码:

    [html] view plain copy
     
    1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>  
    2. <%@include file="/common/common.jsp" %>  
    3. <html>  
    4. <head>  
    5.     <title></title>  
    6. </head>  
    7. <body>  
    8. <h2>样片库管理</h2>  
    9.   
    10. <div style="padding:8px;height:auto">  
    11.     参数项名称: <input class="easyui-validatebox" type="text" name="name" data-options="required:true">  
    12.     创建时间: <input class="easyui-datebox" name="createTime" style="80px">  
    13.     <href="#" class="easyui-linkbutton" iconCls="icon-search">查找</a>  
    14.     <href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加</a>  
    15. </div>  
    16. <table id="tt" class="easyui-datagrid" style="910px;height:350px"  
    17.        title="参数项列表" iconCls="icon-save"  
    18.        rownumbers="false" pagination="true">  
    19. </table>  
    20.   
    21. <script type="text/javascript">  
    22.   
    23.     $('#tt').datagrid({  
    24.         title: "参数项列表",  
    25.         url: '/getAllParam',  
    26.         pageSize:5,  
    27.           
    28.         columns: [  
    29.             [  
    30.                 {field: 'paramId', title: '参数ID',  180, align: "center"},  
    31.                 {field: 'paramName', title: '参数名称',  180, align: "center"},  
    32.                 {field: 'paramLabel', title: '标签',  180, align: 'center'},  
    33.                 {field: 'createTime', title: '创建时间',  180, align: "center"}  
    34.             ]  
    35.         ], toolbar: [  
    36.             {  
    37.                 text: '添加',  
    38.                 iconCls: 'icon-add',  
    39.                 handler: function () {  
    40.                     openDialog("add_dialog", "add");  
    41.                 }  
    42.             },  
    43.             '-',  
    44.             {  
    45.                 text: '修改',  
    46.                 iconCls: 'icon-edit',  
    47.                 handler: function () {  
    48.                     openDialog("add_dialog", "edit");  
    49.                 }  
    50.             },  
    51.             '-',  
    52.             {  
    53.                 text: '删除',  
    54.                 iconCls: 'icon-remove',  
    55.                 handler: function () {  
    56.                     delAppInfo();  
    57.                 }  
    58.             }  
    59.         ]  
    60.     });  
    61.   
    62.     //设置分页控件  
    63.     var p = $('#tt').datagrid('getPager');  
    64.     p.pagination({  
    65.         pageSize: 5,//每页显示的记录条数,默认为10  
    66.         pageList: [5, 10, 15],//可以设置每页记录条数的列表  
    67.         beforePageText: '第',//页数文本框前显示的汉字  
    68.         afterPageText: '页    共 {pages} 页',  
    69.         displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'  
    70.     });  
    71. </script>  
    72. </body>  
    73. </html>  


    mapper.xml

    [html] view plain copy
     
    1. <!-- 分页查询-->  
    2.     <select id="selectAllPage" resultMap="BaseResultMap" parameterType="java.util.Map" >  
    3.         select  
    4.         <include refid="Base_Column_List"/>  
    5.         from param_item  
    6.         <include refid="Example_Where_Clause"/>  
    7.         limit #{pageIndex},#{pageSize}  
    8.     </select>  


    controller方法

    [java] view plain copy
     
      1. @RequestMapping(value = "getAllParam")  
      2.   public void getAllParam(HttpServletRequest request, HttpServletResponse response,  
      3.                           @RequestParam(required = false, defaultValue = "1") Integer page, //第几页  
      4.                           @RequestParam(required = false, defaultValue = "10") Integer rows, //页数大小  
      5.                           @RequestParam(required = false, defaultValue = "") String paramName,  
      6.                           @RequestParam(required = false, defaultValue = "") String createTime  
      7.   ) throws IOException {  
      8.       JSONObject params = new JSONObject();  
      9.       params.put("pageSize", rows);  
      10.       params.put("pageIndex", (page-1)*rows);  
      11.       if (StringUtil.notEmpty(paramName)) {  
      12.           params.put("paramName", paramName);  
      13.       }  
      14.       if (StringUtil.notEmpty(createTime)) {  
      15.   
      16.       }  
      17.       List list = paramItemService.getAllItemPage(params);  
      18.       JSONObject result = new JSONObject();  
      19.       result.put("rows", list);  
      20.       result.put("total", 11);  
      21.       ResponseUtil.sendJsonNoCache(response, result.toJSONString());  
      22.   }  
  • 相关阅读:
    构建Web API服务
    AutoMapper(七)
    AutoMapper(六)
    AutoMapper(五)
    AutoMapper(四)
    AutoMapper(三)
    递归函数练习:输出菲波拉契(Fibonacci)数列的前N项数据
    递归程序练习:输出十进制数的二进制表示
    递归函数练习——累乘
    递归练习——累加和
  • 原文地址:https://www.cnblogs.com/telwanggs/p/5455742.html
Copyright © 2020-2023  润新知