jsp資料庫分頁
發布時間: 2025-09-10 05:52:32
⑴ java編程中用iterator迭代器在jsp中顯示資料庫中的數據,如何實現分頁顯示
列出表中1-n(當前頁最後一條要顯示的)直接的數據,然後排除1-m直接上頁之前的數據,剩下的就是要顯示的。
每頁顯示20條,當前頁需要顯示的是181-200之間的記錄。
(selecttop180fromtablea)
如果只想在Java代碼中實現,迭代器並沒有記錄當前的記錄位置,可能要使用一個計數變數才可以實現。
publicstaticfinalintPAGE_SIZE=20;//每頁顯示的記錄數intvisited=180;//上頁或者更早已經顯示了的
intcurrent=1;//當前的記錄遍歷位置
while(mResultSet.next()){
if(current++<=visited||current>=visited+PAGE_SIZE){
continue;
}
Typevariable=mResultSet.getXxx(param);//處理數據顯示
/...putintomodel
}
熱點內容