記得我還在念大學(xué)的時(shí)候,一位教我們單片機(jī)的老師說(shuō)了一句話:"學(xué)習(xí)編程剛開(kāi)始你就得照葫蘆畫(huà)瓢...",以前我在mysql中分頁(yè)都是用的 limit 100000,20這樣的方式,我相信你也是吧,但是要提高效率,讓分頁(yè)的代碼效率更高一些,更快一些,那我們又該怎么做呢?
成都創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿(mǎn)足客戶(hù)于互聯(lián)網(wǎng)時(shí)代的雙清網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
第一部分:看一下分頁(yè)的基本原理:
第一部分:看一下分頁(yè)的基本原理:
mysql explain SELECT * FROM message ORDER BY id DESC LIMIT 10000, 20
***************** 1. row **************
id: 1
select_type: SIMPLE
table: message
type: index
possible_keys: NULL
key: PRIMARY
key_len: 4
ref: NULL
rows: 10020
Extra:
1 row in set (0.00 sec) 對(duì)上面的mysql語(yǔ)句說(shuō)明:limit 10000,20的意思掃描滿(mǎn)足條件的10020行,扔掉前面的10000行,返回最后的20行,問(wèn)題就在這里,如果是limit 100000,100,需要掃描100100行,在一個(gè)高并發(fā)的應(yīng)用里,每次查詢(xún)需要掃描超過(guò)10W行,性能肯定大打折扣。文中還提到limit n性能是沒(méi)問(wèn)題的,因?yàn)橹粧呙鑞行。
第二部分:根據(jù)雅虎的幾位工程師帶來(lái)了一篇Efficient Pagination Using MySQL的報(bào)告內(nèi)容擴(kuò)展:在文中提到一種clue的做法,給翻頁(yè)提供一些線索,比如還是SELECT * FROM message ORDER BY id DESC,按id降序分頁(yè),每頁(yè)20條,當(dāng)前是第10頁(yè),當(dāng)前頁(yè)條目id最大的是1020,最小的是1000,如果我們只提供上一頁(yè)、下一頁(yè)這樣的跳轉(zhuǎn)(不提供到第N頁(yè)的跳轉(zhuǎn)),那么在處理上一頁(yè)的時(shí)候SQL語(yǔ)句可以是:
完整請(qǐng)到:
Mysql的分頁(yè)關(guān)鍵點(diǎn)在查詢(xún)時(shí)的 limit $iStart,$iEnd;//起初值與總長(zhǎng)度
舉例:selece * from myTable1 order by id desc limit 0,10;
從0開(kāi)始取前10條數(shù)據(jù),取第二頁(yè)的內(nèi)容時(shí),limit 10,10;即可
如有疑問(wèn)去博客加好友,不清楚的再問(wèn)我,有時(shí)間我再寫(xiě)幾篇這樣的文章
先看一下分頁(yè)的基本原理(我拿的是CSDN那個(gè)百萬(wàn)級(jí)數(shù)據(jù)庫(kù)來(lái)測(cè)試?。篠ELECT * FROM `csdn` ORDER BY id DESC LIMIT 100000,2000;
耗時(shí): 0.813ms分析:對(duì)上面的mysql語(yǔ)句說(shuō)明:limit 100000,2000的意思掃描滿(mǎn)足條件的102000行,扔掉前面的100000行,返回最后的2000行。問(wèn)題就在這里,如果是limit 100000,20000,需要掃描120000行,在一個(gè)高并發(fā)的應(yīng)用里,每次查詢(xún)需要掃描超過(guò)100000行,性能肯定大打折扣。在《efficient pagination using mysql》中提出的clue方式。利用clue方法,給翻頁(yè)提供一些線索,比如還是SELECT * FROM `csdn` order by id desc,按id降序分頁(yè),每頁(yè)2000條,當(dāng)前是第50頁(yè),當(dāng)前頁(yè)條目id最大的是102000,最小的是100000。如果我們只提供上一頁(yè)、下一頁(yè)這樣的跳轉(zhuǎn)(不提供到第N頁(yè)的跳轉(zhuǎn))。那么在處理上一頁(yè)的時(shí)候SQL語(yǔ)句可以是:
SELECT * FROM `csdn` WHERE id=102000 ORDER BY id DESC LIMIT 2000; #上一頁(yè)
耗時(shí):0.015ms處理下一頁(yè)的時(shí)候SQL語(yǔ)句可以是:
耗時(shí):0.015ms這樣,不管翻多少頁(yè),每次查詢(xún)只掃描20行。效率大大提高了!但是,這樣分頁(yè)的缺點(diǎn)是只能提供上一頁(yè)、下一頁(yè)的鏈接形式。
直接用limit start, count分頁(yè)語(yǔ)句, 也是我程序中用的方法:
select * from product limit start, count
當(dāng)起始頁(yè)較小時(shí),查詢(xún)沒(méi)有性能問(wèn)題,我們分別看下從10, 100, 1000, 10000開(kāi)始分頁(yè)的執(zhí)行時(shí)間(每頁(yè)取20條), 如下:
select * from product limit 10, 20 0.016秒
select * from product limit 100, 20 0.016秒
select * from product limit 1000, 20 0.047秒
select * from product limit 10000, 20 0.094秒
我們已經(jīng)看出隨著起始記錄的增加,時(shí)間也隨著增大, 這說(shuō)明分頁(yè)語(yǔ)句limit跟起始頁(yè)碼是有很大關(guān)系的,那么我們把起始記錄改為40w看下(也就是記錄的一般左右) select * from product limit 400000, 20 3.229秒
再看我們?nèi)∽詈笠豁?yè)記錄的時(shí)間
select * from product limit 866613, 20 37.44秒
難怪搜索引擎抓取我們頁(yè)面的時(shí)候經(jīng)常會(huì)報(bào)超時(shí),像這種分頁(yè)最大的頁(yè)碼頁(yè)顯然這種時(shí)
間是無(wú)法忍受的。
從中我們也能總結(jié)出兩件事情:
1)limit語(yǔ)句的查詢(xún)時(shí)間與起始記錄的位置成正比
2)mysql的limit語(yǔ)句是很方便,但是對(duì)記錄很多的表并不適合直接使用。
--1.最常用的分頁(yè)select * from content order by id desc limit 0, 10;--limit是MySQL中特有的分頁(yè)語(yǔ)法,用法如下:--舉例:select * from tableName limit 5; --返回前5行select * from tableName limit 0,5; --同上,返回前5行select * from tableName limit 5,10; --返回6-15行
分類(lèi): 電腦/網(wǎng)絡(luò) 軟件
問(wèn)題描述:
我制作的是留言版,回復(fù)時(shí)得弄分頁(yè),但是不知道分頁(yè)怎么弄,網(wǎng)上的代碼沒(méi)有注釋?zhuān)部床欢?/p>
請(qǐng)各位大哥大姐們一定要幫幫我,后面加上注釋?zhuān)x謝!
注意:我不用JavaBean寫(xiě),就用前臺(tái)寫(xiě)。
解析:
作為參考:
%@ page contentType="text/;charset=8859_1" %
%
變量聲明
java.sql.Connection sqlCon; 數(shù)據(jù)庫(kù)連接對(duì)象
java.sql.Statement sqlStmt; SQL語(yǔ)句對(duì)象
java.sql.ResultSet sqlRst; 結(jié)果集對(duì)象
javang.String strCon; 數(shù)據(jù)庫(kù)連接字符串
javang.String strSQL; SQL語(yǔ)句
int intPageSize; 一頁(yè)顯示的記錄數(shù)
int intRowCount; 記錄總數(shù)
int intPageCount; 總頁(yè)數(shù)
int intPage; 待顯示頁(yè)碼
javang.String strPage;
int i;
設(shè)置一頁(yè)顯示的記錄數(shù)
intPageSize = 2;
取得待顯示頁(yè)碼
strPage = request.getParameter("page");
if(strPage==null){表明在QueryString中沒(méi)有page這一個(gè)參數(shù),此時(shí)顯示第一頁(yè)數(shù)據(jù)
intPage = 1;
}
else{將字符串轉(zhuǎn)換成整型
intPage = javang.Integer.parseInt(strPage);
if(intPage1) intPage = 1;
}
裝載JDBC驅(qū)動(dòng)程序
java.sql.DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
設(shè)置數(shù)據(jù)庫(kù)連接字符串
strCon = "jdbc:oracle:thin:@linux:1521:ora4cweb";
連接數(shù)據(jù)庫(kù)
sqlCon = java.sql.DriverManager.getConnection(strCon,"hzq","hzq");
創(chuàng)建一個(gè)可以滾動(dòng)的只讀的SQL語(yǔ)句對(duì)象
sqlStmt = sqlCon.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
準(zhǔn)備SQL語(yǔ)句
strSQL = "select name,age from test";
執(zhí)行SQL語(yǔ)句并獲取結(jié)果集
sqlRst = sqlStmt.executeQuery(strSQL);
獲取記錄總數(shù)
sqlRstst();
intRowCount = sqlRst.getRow();
記算總頁(yè)數(shù)
intPageCount = (intRowCount+intPageSize-1) / intPageSize;
調(diào)整待顯示的頁(yè)碼
if(intPageintPageCount) intPage = intPageCount;
%
head
meta -equiv="Content-Type" content="text/; charset=gb2312"
titleJSP數(shù)據(jù)庫(kù)操作例程 - 數(shù)據(jù)分頁(yè)顯示 - JDBC 2.0 - Oracle/title
/head
body
table border=1 cellspacing="0" cellpadding="0"
tr
th姓名/th
th年齡/th
/tr
%
if(intPageCount0){
將記錄指針定位到待顯示頁(yè)的第一條記錄上
sqlRst.absolute((intPage-1) * intPageSize + 1);
顯示數(shù)據(jù)
i = 0;
while(iintPageSize !sqlRst.isAfterLast()){
%
tr
td%=sqlRst.getString(1)%/td
td%=sqlRst.getString(2)%/td
/tr
%
sqlRst.next();
i++;
}
}
%
/table
第%=intPage%頁(yè) 共%=intPageCount%頁(yè) %if(intPageintPageCount){%a href="jdbc20-oracle.jsp?page=%=intPage+1%"下一頁(yè)/a%}% %if(intPage1){%a href="jdbc20-oracle.jsp?page=%=intPage-1%"上一頁(yè)/a%}%
/body
/
%
關(guān)閉結(jié)果集
sqlRst.close();
關(guān)閉SQL語(yǔ)句對(duì)象
sqlStmt.close();
關(guān)閉數(shù)據(jù)庫(kù)
sqlCon.close();
%
可以試試先!
祝你好運(yùn)!
----------------------------------
也可以用jsp+xml+來(lái)實(shí)現(xiàn),下面給出一個(gè)saucer(思?xì)w)給的xml+的分頁(yè)例子,不妨參考一下:
body
!--the following XML document is "stolen" from MSXML4 documentation--
xml id="xmldoc"
catalog
book id="bk101"
authorGambardella, Matthew/author
titleXML Developer's Guide/title
genreComputer/genre
price44.95/price
publish_date2000-10-01/publish_date
descriptionAn in-depth look at creating applications
with XML./description
/book
book id="bk102"
authorRalls, Kim/author
titleMidnight Rain/title
genreFantasy/genre
price5.95/price
publish_date2000-12-16/publish_date
descriptionA former architect battles corporate zombies,
an evil sorceress, and her own childhood to bee queen
of the world./description
/book
book id="bk103"
authorCorets, Eva/author
titleMaeve Ascendant/title
genreFantasy/genre
price5.95/price
publish_date2000-11-17/publish_date
descriptionAfter the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society./description
/book
book id="bk104"
authorCorets, Eva/author
titleOberon's Legacy/title
genreFantasy/genre
price5.95/price
publish_date2001-03-10/publish_date
descriptionIn post-apocalypse England, the mysterious
agent known only as Oberon helps to create a new life
for the inhabitants of London. Sequel to Maeve
Ascendant./description
/book
book id="bk105"
authorCorets, Eva/author
titleThe Sundered Grail/title
genreFantasy/genre
price5.95/price
publish_date2001-09-10/publish_date
descriptionThe o daughters of Maeve, half-sisters,
battle one another for control of England. Sequel to
Oberon's Legacy./description
/book
book id="bk106"
authorRandall, Cynthia/author
titleLover Birds/title
genreRomance/genre
price4.95/price
publish_date2000-09-02/publish_date
descriptionWhen Carla meets Paul at an ornithology
conference, tempers fly as feathers get ruffled./description
/book
book id="bk107"
authorThurman, Paula/author
titleSplish Splash/title
genreRomance/genre
price4.95/price
publish_date2000-11-02/publish_date
descriptionA deep sea diver finds true love enty
thousand leagues beneath the sea./description
/book
book id="bk108"
authorKnorr, Stefan/author
titleCreepy Crawlies/title
genreHorror/genre
price4.95/price
publish_date2000-12-06/publish_date
descriptionAn anthology of horror stories about roaches,
centipedes, scorpions and other insects./description
/book
/catalog
/xml
table id="mytable" datasrc="#xmldoc" border=1 DATAPAGESIZE="2"
theadthTitle/ththAuthor/ththGenre/ththPublish Date/ththPrice/th/thead
tbodytr
tdspan datafld="title"/span/td
tdspan datafld="author"/span/td
tdspan datafld="genre"/span/td
tdspan datafld="publish_date"/span/td
tdspan datafld="price"/span/td
/tr
/tbody
/table
input type=button value="previous page" onclick="mytable.previousPage()"
input type=button value="next page" onclick="mytable.nextPage()"
/body
/
------------------------------------
分頁(yè)顯示的模板程序
!--show_page.jsp--
%@ page import="javang.*" import="java.sql.*" import="java.util.*" contentType="text/;charset=GB2312"%
%@ page import="tax.*"%
jsp:useBean id="RegisterBean" class="tax.RegisterBean" scope="page"/
jsp:useBean id="itemlist" class="tax.itemlist" scope="page"/
%
int PageSize = 10;設(shè)置一頁(yè)顯示的記錄數(shù)
int PageNum = 1; 初始化頁(yè)碼=1
int PageNumCount = (136+PageSize-1) / PageSize;記算總頁(yè)數(shù)
計(jì)算要顯示的頁(yè)碼
String strPageNum = request.getParameter("page");取得href提交的頁(yè)碼
if(strPageNum==null){ 表明在QueryString中沒(méi)有page這一個(gè)參數(shù),此時(shí)顯示第一頁(yè)數(shù)據(jù)
PageNum = 1;
}
else{
PageNum = javang.Integer.parseInt(strPageNum);將字符串轉(zhuǎn)換成整型
if(PageNum1) PageNum = 1;
}
if(PageNumPageNumCount) PageNum = PageNumCount;調(diào)整待顯示的頁(yè)碼
%
head
meta -equiv="Content-Type" content="text/; charset=gb2312"
titleJSP例程 - 數(shù)據(jù)分頁(yè)顯示 -JDK1.2 /title
/head
body
%
if(PageNumCount0){
out.println(PageNum);顯示數(shù)據(jù),此處只簡(jiǎn)單的顯示頁(yè)數(shù)
}
/*需要顯示的數(shù)據(jù),在此處顯示
、、、
例如:
*/
顯示一個(gè)簡(jiǎn)單的表格
%
table border=1 cellspacing="0" cellpadding="0"
tr
th總數(shù)/th
th頁(yè)數(shù)/th
/tr
tr
th%=PageNumCount%/th
th%=PageNum%/th
/tr
/table
第%=PageNum%頁(yè) 共%=PageNumCount%頁(yè)
%if(PageNumPageNumCount){%a href="show_page.jsp?page=%=PageNum+1%"下一頁(yè)/a%}%
%if(PageNum1){%a href="show_page?page=%=PageNum-1%"上一頁(yè)/a%}%
/body
/
---------------------------------
一個(gè)bean,按照文檔說(shuō)的用。也希望你給出修改意見(jiàn)。
package mshtang;
/**
* pTitle: DataBaseQuery/p
* pDescription: 用于數(shù)據(jù)庫(kù)翻頁(yè)查詢(xún)操作/p
* pCopyright: 廈門(mén)一方軟件公司版權(quán)所有Copyright (c) 2002/p
* pCompany: 廈門(mén)一方軟件公司/p
* @author 小唐蔡
* @version 1.0
*/
import java.sql.*;
import javax.servlet..*;
import java.util.*;
import mshtang.StringAction;
public class DataBaseQuery
{
private HttpServletRequest request;
private StringAction S;
private String sql;
private String userPara;
private String[][] resultArray;
private String[] columnNameArray;
private String[] columnTypeArray;
private int pageSize;
private int columnCount;
private int currentPageNum;
private int currentPageRecordNum;
private int totalPages;
private int pageStartRecord;
private int totalRecord;
private static boolean initSuccessful;
private String currentJSPPageName;
private String displayMessage;
public DataBaseQuery()
{
S = new StringAction();
sql = "";
pageSize = 10;
totalRecord = 0;
initSuccessful = false;
currentJSPPageName = "";
displayMessage = "";
columnNameArray = null;
columnTypeArray = null;
currentPageRecordNum = 0;
columnCount = 0;
}
/**功能:數(shù)據(jù)庫(kù)初始化操作,其它操作的前提。
*
* @param conn:數(shù)據(jù)庫(kù)連接;
* @param request:jsp頁(yè)面request對(duì)象;
* @param querySQL:查詢(xún)語(yǔ)句;
* @param pageSize:每頁(yè)顯示記錄數(shù);
* @param startPageNum:開(kāi)始顯示頁(yè)碼
*/
public void init(Connection conn, HttpServletRequest request, String querySQL, int pageSize, int startPageNum)
{
if(conn != null)
{
this.request = request;
this.sql = request.getParameter("querySQL");
this.userPara = request.getParameter("userPara");
if(sql == null || sql.equals(""))
{
sql = querySQL;
}
if(this.userPara == null)
{
this.userPara = "";
}
if(S.isContains(sql, "select;from", ";", true))
{
try
{
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(sql);
ResultSetMetaData r *** d = rs.getMetaData();
columnCount = r *** d.getColumnCount();
columnNameArray = new String[columnCount];
columnTypeArray = new String[columnCount];
String columnName;
String value;
while(rs.next())
{
totalRecord++;
if(totalRecord == 1)
{
for(int i = 0; i columnCount; i++)
{
columnNameArray[i] = r *** d.getColumnName(i + 1);
columnTypeArray[i] = r *** d.getColumnTypeName(i + 1);
}
}
}
rs.close();
在總記錄數(shù)大于0的情況下進(jìn)行下列操作
獲取鏈接圖象
if(totalRecord 0 pageSize 0 columnCount 0 startPageNum 0)
{
獲取總頁(yè)數(shù)
totalPages = totalRecord / pageSize;
int tempNum = totalRecord % pageSize;
if(tempNum != 0)
{
totalPages++;
}
獲得當(dāng)前頁(yè)頁(yè)碼
String currentPage = request.getParameter("currentPageNum");
currentPageNum = (currentPage == null || currentPage.equals(""))? startPageNum:Integer.parseInt(currentPage);
currentPageNum = (currentPageNum totalPages)?totalPages:currentPageNum;
currentPageNum = (currentPageNum = 0)?1:currentPageNum;
獲得當(dāng)前頁(yè)起始顯示記錄數(shù)
pageStartRecord = (currentPageNum - 1) * pageSize + 1;
pageStartRecord = (pageStartRecord = 0)?1:pageStartRecord;
pageStartRecord = (pageStartRecord totalRecord)?totalRecord:pageStartRecord;
獲得當(dāng)前頁(yè)顯示記錄數(shù)
if(currentPageNum * pageSize totalRecord)
{
currentPageRecordNum = totalRecord - (currentPageNum - 1) * pageSize;
}
else
{
currentPageRecordNum = pageSize;
}
resultArray = new String[currentPageRecordNum][columnCount];
用于跳過(guò)前面不需顯示的記錄
int continueRowNum = 0;
用于跳過(guò)后面不再顯示的記錄
int breakRowNum = 0;
ResultSet rs2 = st.executeQuery(sql);
while(rs2.next())
{
跳過(guò)前面不需顯示的記錄
continueRowNum++;
if(continueRowNum pageStartRecord)
{
continue;
}
存取當(dāng)前頁(yè)需顯示的記錄到二維數(shù)組
for(int i = 0; i columnCount; i++)
{
value = rs2.getString(columnNameArray[i]);
value = (value == null)?"":value.trim();
resultArray[breakRowNum][i] = value;
}
跳過(guò)后面不再顯示的記錄
breakRowNum++;
if(breakRowNum = currentPageRecordNum)
{
break;
}
}
rs2.close();
}
st.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
transferSQL(sql);
initSuccessful = true;
}
}
/**功能:數(shù)據(jù)庫(kù)初始化操作,其它操作的前提,默認(rèn)每頁(yè)顯示10條記錄。
*
* @param conn:數(shù)據(jù)庫(kù)連接;
* @param request:jsp頁(yè)面request對(duì)象;
* @param querySQL:查詢(xún)語(yǔ)句;
* @param startPageNum:開(kāi)始顯示頁(yè)碼
*/
public void init(Connection conn, HttpServletRequest request, String querySQL, int startPageNum)
{
init(conn, request, querySQL, 10, startPageNum);
}
/**功能:數(shù)據(jù)庫(kù)初始化操作,其它操作的前提,默認(rèn)從第一頁(yè)開(kāi)始顯示。
*
* @param conn:數(shù)據(jù)庫(kù)連接;
* @param request:jsp頁(yè)面request對(duì)象;
* @param querySQL:查詢(xún)語(yǔ)句;
* @param pageSize:每頁(yè)顯示記錄數(shù);
*/
public void init(Connection conn, HttpServletRequest request, int pageSize, String querySQL)
{
init(conn, request, querySQL, pageSize, 1);
}
/**功能:數(shù)據(jù)庫(kù)初始化操作,其它操作的前提,默認(rèn)從第一頁(yè)開(kāi)始顯示,每頁(yè)顯示10條記錄。
*
* @param conn:數(shù)據(jù)庫(kù)連接;
* @param request:jsp頁(yè)面request對(duì)象;
* @param querySQL:查詢(xún)語(yǔ)句;
*/
public void init(Connection conn, HttpServletRequest request, String querySQL)
{
init(conn, request, querySQL, 10, 1);
}
/**功能:給出沒(méi)有初始化的提醒信息,內(nèi)部調(diào)用。
*
*/
private static void getMessage()
{
if(!initSuccessful)
{
System.out.println("沒(méi)有完成初始化");
}
}
/**功能:得到查詢(xún)結(jié)果的總記錄數(shù)。
*
* @return
*/
public int getTotalRecord()
{
getMessage();
return totalRecord;
}
/**功能:得到當(dāng)前頁(yè)的頁(yè)碼
*
* @return
*/
public int getCurrentPageNum()
{
getMessage();
return currentPageNum;
}
/**功能:獲得當(dāng)前頁(yè)記錄數(shù)
*
* @return
*/
public int getCurrentPageRecord()
{
getMessage();
return currentPageRecordNum;
}
/**功能:獲得總頁(yè)數(shù)
*
* @return
*/
public int getTotalPages()
{
getMessage();
return totalPages;
}
/**獲得調(diào)用該javaBean的jsp頁(yè)面文件名,用于翻頁(yè)操作,可以免去外界輸入頁(yè)面參數(shù)的錯(cuò)誤,用于內(nèi)部調(diào)用。
*
* @return:調(diào)用該javaBean的jsp頁(yè)面文件名
*/
private String getCurrentJSPPageName()
{
getMessage();
if(request != null)
{
String tempPage = request.getRequestURI();
String[] tempArray = S.stringSplit(tempPage, "/");
if(tempArray != null tempArray.length 0)
{
currentJSPPageName = tempArray[tempArray.length - 1];
}
}
return currentJSPPageName;
}
/**功能:用于顯示圖片鏈接或字符串(上一頁(yè)、下一頁(yè)等鏈接)。用于翻頁(yè)操作,內(nèi)部調(diào)用
*
* @param imageSource:圖片來(lái)源;
* @param i:翻頁(yè)信息,1表示第一頁(yè),2表示上一頁(yè),3表示下一頁(yè),4表示尾頁(yè),
* @return:顯示的鏈接圖片或鏈接文字
*/
private void displayMessage(String imageSource, int i)
{
getMessage();
if(imageSource != null !imageSource.equals(""))
{
displayMessage = "img src=\"" + imageSource + "\" border=\"0\"";
}
else
{
switch(i)
{
case 1:
displayMessage = "font size=\"2\"[首頁(yè)]/font";
break;
case 2:
displayMessage = "font size=\"2\"[上一頁(yè)]/font";
break;
case 3:
displayMessage = "font size=\"2\"[下一頁(yè)]/font";
break;
case 4:
displayMessage = "font size=\"2\"[尾頁(yè)]/font";
}
}
}
/**功能:鏈接到相應(yīng)頁(yè)面,內(nèi)部調(diào)用。
*
* @param imageSource:圖片來(lái)源;
* @param i:翻頁(yè)信息,1表示第一頁(yè),2表示上一頁(yè),3表示下一頁(yè),4表示尾頁(yè),
* @return:相應(yīng)頁(yè)面的鏈接
*/
private String getNavigation(String imageSource, int i)
{
displayMessage(imageSource, i);
int pageNum = 0;
switch(i)
{
case 1:
pageNum = 1;
break;
case 2:
pageNum = currentPageNum - 1;
break;
case 3:
pageNum = currentPageNum + 1;
break;
case 4:
pageNum = totalPages;
}
currentJSPPageName = "a columnName, true);
if(resultArray != null columnIndex != -1)
{
columnValue = resultArray[recordIndex][columnIndex];
}
}
return columnValue;
}
/**功能:方法重載。返回特定行特定列的值。
*
* @param recordIndex:行索引,從0開(kāi)始;
* @param columnIndex:列索引,從1開(kāi)始;
* @return
*/
public String g