hays
海納百川
posts - 25, comments - 48, trackbacks - 0, articles - 0
BlogJava
::
首頁
:: ::
聯系
::
聚合
::
管理
頁面分頁函數
Posted on 2006-10-30 15:49
hays(海納百川)
閱讀(240)
評論(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(洞庭散人)
搜索
積分與排名
積分 - 26310
排名 - 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配置(圖)(5665)
2.? eclipse中配置 structs(轉帖)(4173)
3.?JMF實例(二)-接受端(2265)
4.?JMF實例(二)--發送端(2093)
5.?表達式求值(C實現)(1656)
評論排行榜
1.?mysql-front配置(圖)(33)
2.?關于Static與final的個人總結(4)
3.?表達式求值(C實現)(2)
4.?JMF實例(二)--發送端(2)
5.?JMF實例(二)-接受端(1)
主站蜘蛛池模板:
册亨县
|
临高县
|
北安市
|
赤壁市
|
墨江
|
江川县
|
宿松县
|
桂阳县
|
安康市
|
侯马市
|
呼和浩特市
|
会理县
|
泸溪县
|
桐柏县
|
浏阳市
|
登封市
|
翁牛特旗
|
乌兰浩特市
|
迁西县
|
邻水
|
南丹县
|
明水县
|
昂仁县
|
弥勒县
|
襄汾县
|
波密县
|
龙江县
|
岳阳县
|
泊头市
|
神农架林区
|
乌鲁木齐市
|
崇州市
|
丰原市
|
金湖县
|
三明市
|
什邡市
|
咸阳市
|
遵义县
|
东乡族自治县
|
芜湖县
|
黑河市
|