@xieamao
dao.query()中是使用Hibernate實(shí)現(xiàn)分頁(yè)的查詢,在有很多現(xiàn)成的實(shí)現(xiàn)。
@yushibo
public class Page {
static private int DEFAULT_PAGE_SIZE = 15;
/**
* 每頁(yè)的記錄數(shù)
*/
private int pageSize = DEFAULT_PAGE_SIZE;
/**
* 當(dāng)前頁(yè)第一條數(shù)據(jù)在List中的位置,從0開(kāi)始
*/
private int start;
/**
* 當(dāng)前頁(yè)中存放的記錄
*/
private List results;
/**
* 總記錄數(shù)
*/
private int totalCount;
/**
* 構(gòu)造方法,只構(gòu)造空頁(yè)
*/
public Page() {
this(0, 0, DEFAULT_PAGE_SIZE, new ArrayList());
}
/**
* 默認(rèn)構(gòu)造方法
*
* @param start
* 本頁(yè)數(shù)據(jù)在數(shù)據(jù)庫(kù)中的起始位置
* @param totalSize
* 數(shù)據(jù)庫(kù)中總記錄條數(shù)
* @param pageSize
* 本頁(yè)容量
* @param results
* 本頁(yè)包含的數(shù)據(jù)
*/
public Page(int start, int totalSize, int pageSize, List results) {
this.pageSize = pageSize;
this.start = start;
this.totalCount = totalSize;
this.results = results;
}
/**
* 取數(shù)據(jù)庫(kù)中包含的總記錄數(shù)
*/
public int getTotalCount() {
return this.totalCount;
}
/**
* 取總頁(yè)數(shù)
*/
public int getTotalPageCount() {
if (totalCount % pageSize == 0)
return totalCount / pageSize;
else
return totalCount / pageSize + 1;
}
/**
* 取每頁(yè)數(shù)據(jù)容量
*/
public int getPageSize() {
return pageSize;
}
/**
* 當(dāng)前頁(yè)記錄
*/
public List getResults() {
return results;
}
/**
* 取當(dāng)前頁(yè)碼,頁(yè)碼從1開(kāi)始
*/
public int getCurrentPageNo() {
return start / pageSize + 1;
}
/**
* 是否有下一頁(yè)
*/
public boolean hasNextPage() {
return this.getCurrentPageNo() < this.getTotalPageCount() - 1;
}
/**
* 是否有上一頁(yè)
*/
public boolean hasPreviousPage() {
return this.getCurrentPageNo() > 1;
}
/**
* 獲取任一頁(yè)第一條數(shù)據(jù)的位置,每頁(yè)條數(shù)使用默認(rèn)值
*/
protected static int getStartOfPage(int pageNo) {
return getStartOfPage(pageNo, DEFAULT_PAGE_SIZE);
}
/**
* 獲取任一頁(yè)第一條數(shù)據(jù)的位置,startIndex從0開(kāi)始
*/
public static int getStartOfPage(int pageNo, int pageSize) {
return (pageNo - 1) * pageSize;
}
/**
* 設(shè)置總記錄數(shù)
*/
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
/**
* 設(shè)置記錄
* @param results
*/
public void setResults(List results) {
this.results = results;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
}
@佳佳
這個(gè)ModelAndView是Spring中的類(lèi),具體可以參考這里:
http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/ModelAndView.html也可以換成是Struts的實(shí)現(xiàn),這只是用在page和controller之間傳遞參數(shù)用的,和用request是一樣的。
@迷途羔羊
排序是要自己寫(xiě)代碼實(shí)現(xiàn)的,所以叫 external paging嘛。
@fenix
就靈活性和可擴(kuò)展性來(lái)說(shuō),eXtremeComponents更好一些。
@佳佳
你好,我是用的displaytag1.1,應(yīng)該有這兩個(gè)屬性的,或者你重新下載個(gè)displaytag的包看下:
<attribute>
<name>partialList</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>boolean</type>
<description>enable/disable partialLists. Valid values are true or false</description>
</attribute>
<attribute>
<name>size</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
Used only when partialList=true. Reference to the Integer object containing the size of the total dataset. Can
be an expression like requestScope.object.property. In the EL version of the taglibrary this must be an EL
expression which points to the source object.
</description>
</attribute>
@mm
<h3>前12筆記錄</h3>
<display:table name="test" length="12">
<display:column property="id" title="ID" />
<display:column property="email" />
<display:column property="status" />
</display:table>
可以看看displaytag的例子:
http://displaytag.homeip.net/displaytag-examples-1.1/example-subsets.jsp
是怎么構(gòu)造樹(shù)的呢?是在tree_ajax.js和tree_htfl.js中嗎?哪里可以找到這兩個(gè)文件呢,這兩個(gè)文件所有的內(nèi)容就是文章中提供的js文件的內(nèi)容嗎?最好能提供這兩個(gè)文件的代碼。現(xiàn)在這樣看有點(diǎn)摸不著頭腦。
re: 我的第一次面試經(jīng)歷 zJun's帛羅閣 2006-07-19 11:45
int ch = 'A' - 1;
for (int i = 1; i <= 26; i++) {
for (int j = 1; j <= i; j++) {
System.out.print((char) (ch + i));
}
System.out.println();
}
不是很復(fù)雜啊,是題目還有什么要求沒(méi)有寫(xiě)出來(lái)嗎?