hays
海納百川
posts - 25, comments - 48, trackbacks - 0, articles - 0
BlogJava
::
首頁
:: ::
聯系
::
聚合
::
管理
頁面分頁函數
Posted on 2006-10-30 15:49
hays(海納百川)
閱讀(238)
評論(0)
編輯
收藏
?
package
?com.vitamin.download;
import
?javax.servlet.
*
;
import
?javax.servlet.http.
*
;
import
?java.math.
*
;
import
?java.sql.
*
;
public
?
class
?Pagination?
{
????
????
private
?String?strPage?
=
?
null
;
????
private
?
int
?curPage;
//
當前頁;
????
private
?
int
?m_rows;
//
每頁包括的幾個數據項;
????
private
?
int
?totalPage;
//
總頁數
????
????
public
?Pagination()
????
{
????????
????}
????
????
public
?
int
?getRows()
????
{
????????
return
?
this
.m_rows;
????}
????
????
public
?Pagination(
int
?rows)
????
{
????????
this
.setRows(rows);
????}
????
????
public
?String?getstrPage(HttpServletRequest?request,String?page)
????
{
????????
try
????????
{
????????????????strPage?
=
?request.getParameter(page);
????????}
????????
catch
(Exception?e)
????????
{
????????????????System.out.print(e.getMessage());
????????}
????????
return
?strPage;
????}
????
????
public
?
int
?getcurPage(String?strPage)
????
{
????????
try
????????
{
????????????
if
(strPage
==
null
)
????????????
{
????????????????
this
.curPage?
=
1
;
????????????}
????????????
else
????????????
{
????????????????
this
.curPage?
=
?Integer.parseInt(strPage);
????????????????
if
(
this
.curPage
<
1
)
????????????????
{
????????????????????
this
.curPage?
=
1
;
????????????????}
????????????}
????????????
????????}
????????
catch
(Exception?e)
????????
{
????????????System.out.print(
"
curPages
"
);
????????}
????????
return
?
this
.curPage;
????}
????
?????
public
?
void
?setRows(
int
?rows)
?????
{
???????????m_rows
=
rows;
?????}
???????
//
?取得頁數
??????
?????
public
?
int
?getTotalPages(
int
?rowcounts)
?????
{
???????????
int
?test;
//
?變量
???????????test
=
rowcounts
%
m_rows;
//
?取得余數
???????????
if
(test
==
0
)
???????????
{
???????????????totalPage?
=
?rowcounts
/
m_rows;
//
?可以整除,總頁數;
???????????}
???????????
else
???????????
{
???????????????totalPage
=
rowcounts
/
m_rows
+
1
;
//
?不是的話就加一??
???????????}
???????????
return
?totalPage;
//
?返回頁數
??????}
???????
//
?結果集的返回
???????
?????
public
?ResultSet?getPageSet(ResultSet?rs,
int
?curPages)
?????
{
???????????
if
(curPages
==
1
)
???????????
{
??????????????
???????????????
return
?rs;
//
?如果就只有一頁
???????????}
???????????
else
???????????
{
???????????????
int
?i
=
1
;
???????????????
try
???????????????
{
???????????????????
while
(rs.next())
//
使rs跳到(curPages-1)*m_rows?那行;
???????????????????
{
???????????????????????i
=
i
+
1
;
???????????????????????
if
(i
>
((curPages
-
1
)
*
m_rows))
???????????????????????
{
???????????????????????????
break
;
//
?退出
???????????????????????}
???????????????????}
???????????????????
return
?rs;
//
?從退出開始將結果集返回
???????????????}
???????????????
catch
(Exception?e)
???????????????
{
???????????????????System.out.print(e.getMessage());
???????????????}
???????????}
???????????
return
?rs;
???????}
}
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
Powered by:
BlogJava
Copyright © hays(海納百川)
日歷
<
2006年10月
>
日
一
二
三
四
五
六
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
公告
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(6)
給我留言
查看公開留言
查看私人留言
隨筆分類
(10)
J2EE
J2ME(1)
liunx(3)
共享
生活
自己動手寫操作系統(1)
設計模式(1)
配置(4)
隨筆檔案
(25)
2009年5月 (2)
2009年2月 (1)
2007年11月 (2)
2007年10月 (3)
2007年9月 (1)
2007年3月 (1)
2006年11月 (4)
2006年10月 (3)
2006年6月 (6)
2006年5月 (2)
相冊
144
我的好友
phinecos(洞庭散人)
搜索
積分與排名
積分 - 26244
排名 - 1496
最新評論
1.?re: mysql-front配置(圖)
3q
--jio127
2.?re: mysql-front配置(圖)[未登錄]
3q
--hh
3.?re: 表達式求值(C實現)
十位數就不會算了,需要改進啊
--yelangjunjie
4.?re: mysql-front配置(圖)
Thanks!
--johnhuxley
5.?re: mysql-front配置(圖)[未登錄]
謝謝謝謝!!!!!!
--菜鳥
閱讀排行榜
1.?mysql-front配置(圖)(5656)
2.? eclipse中配置 structs(轉帖)(4171)
3.?JMF實例(二)-接受端(2264)
4.?JMF實例(二)--發送端(2092)
5.?表達式求值(C實現)(1651)
評論排行榜
1.?mysql-front配置(圖)(33)
2.?關于Static與final的個人總結(4)
3.?表達式求值(C實現)(2)
4.?JMF實例(二)--發送端(2)
5.?JMF實例(二)-接受端(1)
主站蜘蛛池模板:
内乡县
|
武平县
|
黎川县
|
昔阳县
|
雷州市
|
亚东县
|
秦皇岛市
|
襄城县
|
洛南县
|
北川
|
收藏
|
湟源县
|
合作市
|
兴山县
|
惠安县
|
龙泉市
|
大姚县
|
灵璧县
|
连南
|
江孜县
|
彰武县
|
玛曲县
|
樟树市
|
行唐县
|
富锦市
|
独山县
|
高雄县
|
界首市
|
昌邑市
|
册亨县
|
东兴市
|
勐海县
|
富宁县
|
广州市
|
托里县
|
惠水县
|
丹江口市
|
汝州市
|
舟山市
|
新晃
|
聂荣县
|