頁面展示效果。
頁面代碼:
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <%@include file="/common/common.jsp" %>
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <h2>樣片庫管理</h2>
- <div style="padding:8px;height:auto">
- 參數項名稱: <input class="easyui-validatebox" type="text" name="name" data-options="required:true">
- 創建時間: <input class="easyui-datebox" name="createTime" style="width:80px">
- <a href="#" class="easyui-linkbutton" iconCls="icon-search">查找</a>
- <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加</a>
- </div>
- <table id="tt" class="easyui-datagrid" style="width:910px;height:350px"
- title="參數項列表" iconCls="icon-save"
- rownumbers="false" pagination="true">
- </table>
- <script type="text/javascript">
- $('#tt').datagrid({
- title: "參數項列表",
- url: '/getAllParam',
- pageSize:5,
- columns: [
- [
- {field: 'paramId', title: '參數ID', width: 180, align: "center"},
- {field: 'paramName', title: '參數名稱', width: 180, align: "center"},
- {field: 'paramLabel', title: '標籤', width: 180, align: 'center'},
- {field: 'createTime', title: '創建時間', width: 180, align: "center"}
- ]
- ], toolbar: [
- {
- text: '添加',
- iconCls: 'icon-add',
- handler: function () {
- openDialog("add_dialog", "add");
- }
- },
- '-',
- {
- text: '修改',
- iconCls: 'icon-edit',
- handler: function () {
- openDialog("add_dialog", "edit");
- }
- },
- '-',
- {
- text: '刪除',
- iconCls: 'icon-remove',
- handler: function () {
- delAppInfo();
- }
- }
- ]
- });
- //設置分頁控件
- var p = $('#tt').datagrid('getPager');
- p.pagination({
- pageSize: 5,//每頁顯示的記錄條數,默認爲10
- pageList: [5, 10, 15],//可以設置每頁記錄條數的列表
- beforePageText: '第',//頁數文本框前顯示的漢字
- afterPageText: '頁 共 {pages} 頁',
- displayMsg: '當前顯示 {from} - {to} 條記錄 共 {total} 條記錄'
- });
- </script>
- </body>
- </html>
mapper.xml
- <!-- 分頁查詢-->
- <select id="selectAllPage" resultMap="BaseResultMap" parameterType="java.util.Map" >
- select
- <include refid="Base_Column_List"/>
- from param_item
- <include refid="Example_Where_Clause"/>
- limit #{pageIndex},#{pageSize}
- </select>
controller方法
- @RequestMapping(value = "getAllParam")
- public void getAllParam(HttpServletRequest request, HttpServletResponse response,
- @RequestParam(required = false, defaultValue = "1") Integer page, //第幾頁
- @RequestParam(required = false, defaultValue = "10") Integer rows, //頁數大小
- @RequestParam(required = false, defaultValue = "") String paramName,
- @RequestParam(required = false, defaultValue = "") String createTime
- ) throws IOException {
- JSONObject params = new JSONObject();
- params.put("pageSize", rows);
- params.put("pageIndex", (page-1)*rows);
- if (StringUtil.notEmpty(paramName)) {
- params.put("paramName", paramName);
- }
- if (StringUtil.notEmpty(createTime)) {
- }
- List list = paramItemService.getAllItemPage(params);
- JSONObject result = new JSONObject();
- result.put("rows", list);
- result.put("total", 11);
- ResponseUtil.sendJsonNoCache(response, result.toJSONString());
- }