JSP 翻頁功能

2021-09-25 23:35:59 字數 2746 閱讀 8972

jsp頁面部分: 

js部分:

// 頁碼跳轉

function totablelist(userid, usergroup, pages) ,

error: function (xhr)

});}

controller部分(此處資料量不大,並不需要用到判斷非空工具類):

public modelandview gettablelist(

string userid, string usergroup, string condition1, string condition2, integer pages,

) if (usergroup == null)

if (condition1 == null)

if (condition2 == null)

if (pages == null)

if (isinit == null)

modelandview modelandview = new modelandview();

// 根據所有的引數確定返回結果共多少頁pagesnum,pages用於傳值,傳過去多少返回來多少

//獲取**結果

listtablelist;

modelandview.addobject("totalpage", totalpage);

modelandview.addobject("tablelist", tablelist);

modelandview.setviewname("index/page/pagetable");

return modelandview;

}附上checkparametersutil工具類:

public class checkparametersutil 

/*** 獲取checkparametersutil例項

* @return checkparametersutil

* @author: xuwei

*/public static checkparametersutil getinstance()

/*** 校驗

* @return datamessage

* @author: xuwei

* @throws exception

*/public void checkparameter() throws exception

} }

public string tostring(object object)

public boolean isempty(collection collection)

public boolean isempty(map map)

public boolean isempty(string string)

public boolean isemptytrim(string string)

public boolean isempty(object object)

public boolean isemptytrim(object object)

public boolean isempty(t array)

}

//獲取結果集行數以判斷頁碼

listgettotalpage_facility(

@param("userid") string userid, @param("condition1") string condition1,

@param("condition2") string condition2, @param("pages") integer pages

);//獲取資訊

listgetfacilityinfolist(

@param("userid") string userid, @param("condition1") string condition1,

@param("condition2") string condition2, @param("pages") integer pages

);

mybatis的xml檔案:

select count(*) as totalpages, cast(count(*)/100 as int)+1 as pagesnum, # as currentpage

,# as condition1, # as condition2

from t_stationinfo

where 1=1

and towncode = #

and condition1 like '%$%'

and condition2 = #

select *

from (select *, row_number() over (order by condition2) as rowno

from (select * from t_stationinfo

where 1 = 1

and towncode = #

and condition1 like '%$%'

and condition2 = #

) a) b

where b.rowno between (# -1)*100 and #*100

order by b.condition1

Jsp中翻頁功能實現

jsp中翻頁功能實現 第一步 新建兩個輔助類 page類 public class page 建構函式,預設 public page 構造方法,對所有屬性進行設定 此處省略set及get構造方法 pageutil類 第二步 在action類中建立page物件,並存入到session中 public ...

listview 翻頁功能簡單實現

listview 翻頁功能簡單實現 includetypedef struct scroll scroll,p scroll 支援按單步移動和按頁移動 如果單步觸發了翻頁,整頁向上 下移動一步 void adjust scroll p scroll scroll int len 測試 int mai...

SFDC 08 翻頁功能

翻頁的原理是資料庫查詢出的資料多,一頁放不下,然後通過設定每次把一定條數的資料放到乙個vf頁面可以獲取的list中,最主要得到其實是乙個迴圈放置的函式。我以account表為例,查出這些資料,我每頁只放三條資料。1 public with sharing class pagejumpcontroll...