溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么實(shí)現(xiàn)SSM分頁

發(fā)布時(shí)間:2022-09-30 10:31:30 來源:億速云 閱讀:97 作者:iii 欄目:開發(fā)技術(shù)

今天小編給大家分享一下怎么實(shí)現(xiàn)SSM分頁的相關(guān)知識(shí)點(diǎn),內(nèi)容詳細(xì),邏輯清晰,相信大部分人都還太了解這方面的知識(shí),所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。

1.頁面用bootstrapTable實(shí)現(xiàn)(配置查詢的參數(shù)即可),前提得引入bootstrapTable的css,js

function load() {    var typeid = $("#typeid").val();
    $('#exampleTable').bootstrapTable({                        method : 'get', // 服務(wù)器數(shù)據(jù)的請(qǐng)求方式 get or post
                        url : "xxx/base/supSupt/list", // 服務(wù)器數(shù)據(jù)的加載地址
                        iconSize : 'outline',                        toolbar : '#exampleToolbar',                        striped : true, // 設(shè)置為true會(huì)有隔行變色效果
                        dataType : "json", // 服務(wù)器返回的數(shù)據(jù)類型
                        pagination : true, // 設(shè)置為true會(huì)在底部顯示分頁條
                        singleSelect : false, // 設(shè)置為true將禁止多選
                        pageSize : 10, // 如果設(shè)置了分頁,每頁數(shù)據(jù)條數(shù)
                        pageNumber : 1, // 如果設(shè)置了分布,首頁頁碼
                        search : true, // 是否顯示搜索框,給參數(shù)就可以搜索了
                        showColumns : false, // 是否顯示內(nèi)容下拉框(選擇顯示的列)
                        clickToSelect:true,                        sortOrder: "desc",                        sidePagination : "server", // 設(shè)置在哪里進(jìn)行分頁,可選值為"client" 或者
                        queryParams : function(params) {//后臺(tái)有個(gè)Query類,只要添加了鍵值對(duì)而且是表中有的他會(huì)自動(dòng)弄進(jìn)去
                            return {                                // 說明:傳入后臺(tái)的參數(shù)包括offset開始索引,limit步長(zhǎng),sort排序列,order:desc或者,以及所有列的鍵值對(duì)
                                limit : params.limit,                                offset : params.offset,sort:"createdat",根據(jù)創(chuàng)建時(shí)間(對(duì)應(yīng)映射文件的條件)
                                                    order:"desc",排序
                                type:typeid
                            };
                        },                        columns : [
                                {                                    checkbox : true
                                },
                                {                                    field : 'code',                                    title : '編碼'
                                                    },
                                {                                    field : 'comp',                                    title : '公司名'
                                },
                                {                                    field : 'busilicence',                                    title : '信用代碼'
                                },
                                {                                    field : 'law',                                    title : '法定代表人'
                                },
                                {                                    field : 'tel',                                    title : '聯(lián)系電話'
                                }]
    })
}

2.控制器

@ResponseBody
    @GetMapping("/list")    @RequiresPermissions("base:supSupt:add")    public PageUtils list(@RequestParam Map<String, Object> params){        //查詢列表數(shù)據(jù)
        Query query = new Query(params);
        List<SupSuptSupVO> supSuptList = supSuptService.getSupListExcludeSuptpyeId(query);        int total = supSuptService.getSupListCountExcludeSuptpyeId(query);
        PageUtils pageUtils = new PageUtils(supSuptList, total);        return pageUtils;
    }

3.工具類

分頁的工具類

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>

以上就是“怎么實(shí)現(xiàn)SSM分頁”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會(huì)為大家更新不同的知識(shí),如果還想學(xué)習(xí)更多的知識(shí),請(qǐng)關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

ssm
AI