本篇文章給大家帶來的內容是關于ssm分頁的方法介紹(代碼示例),有一定的參考價值,有需要的朋友可以參考一下,希望對你有所幫助。
頁面用bootstrapTable實現(配置查詢的參數即可),前提得引入bootstrapTable的css,js
function load() { var typeid = $("#typeid").val(); $('#exampleTable').bootstrapTable({ method : 'get', // 服務器數據的請求方式 get or post url : "xxx/base/supSupt/list", // 服務器數據的加載地址 iconSize : 'outline', toolbar : '#exampleToolbar', striped : true, // 設置為true會有隔行變色效果 dataType : "json", // 服務器返回的數據類型 pagination : true, // 設置為true會在底部顯示分頁條 singleSelect : false, // 設置為true將禁止多選 pageSize : 10, // 如果設置了分頁,每頁數據條數 pageNumber : 1, // 如果設置了分布,首頁頁碼 search : true, // 是否顯示搜索框,給參數就可以搜索了 showColumns : false, // 是否顯示內容下拉框(選擇顯示的列) clickToSelect:true, sortOrder: "desc", sidePagination : "server", // 設置在哪里進行分頁,可選值為"client" 或者 queryParams : function(params) {//后臺有個Query類,只要添加了鍵值對而且是表中有的他會自動弄進去 return { // 說明:傳入后臺的參數包括offset開始索引,limit步長,sort排序列,order:desc或者,以及所有列的鍵值對 limit : params.limit, offset : params.offset, sort:"createdat",根據創建時間(對應映射文件的條件) order:"desc",排序 type:typeid }; }, columns : [ { checkbox : true }, { field : 'code', title : '編碼' }, { field : 'comp', title : '公司名' }, { field : 'busilicence', title : '信用代碼' }, { field : 'law', title : '法定代表人' }, { field : 'tel', title : '聯系電話' }] }) }
2.控制器
@ResponseBody @GetMapping("/list") @RequiresPermissions("base:supSupt:add") public PageUtils list(@RequestParam Map<String, Object> params){ //查詢列表數據 Query query = new Query(params); List<SupSuptSupVO> supSuptList = supSuptService.getSupListExcludeSuptpyeId(query); int total = supSuptService.getSupListCountExcludeSuptpyeId(query); PageUtils pageUtils = new PageUtils(supSuptList, total); return pageUtils; }
- 工具類
分頁的工具類 - mybatis映射文件
<select id="getSupListExcludeSuptpyeId" resultType="com.xxx.bid.base.vo.SupSuptVO"> select * from bid_sup where id not in ( select ss.supid from bid_sup_supt as ss inner join bid_sup as s on ss.supid = s.id <where> <if test="typeid != null and typeid != ''"> and ss.typeid = #{typeid} </if> </where> ) <choose> <when test="sort != null and sort.trim() != ''"> order by ${sort} ${order} </when> <otherwise> order by ls desc </otherwise> </choose> <if test="offset != null and limit != null"> limit #{offset}, #{limit} </if> </select> <select id="getSupListCountExcludeSuptpyeId" resultType="int"> select count(*) from bid_sup where id not in ( select ss.supid from bid_sup_supt as ss inner join bid_sup as s on ss.supid = s.id <where> <if test="typeid != null and typeid != ''"> and ss.typeid = #{typeid} </if> </where> ) </select>
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END