@xieamao
dao.query()中是使用Hibernate實現(xiàn)分頁的查詢,在有很多現(xiàn)成的實現(xiàn)。
@yushibo
public class Page {
static private int DEFAULT_PAGE_SIZE = 15;
/**
* 每頁的記錄數(shù)
*/
private int pageSize = DEFAULT_PAGE_SIZE;
/**
* 當前頁第一條數(shù)據(jù)在List中的位置,從0開始
*/
private int start;
/**
* 當前頁中存放的記錄
*/
private List results;
/**
* 總記錄數(shù)
*/
private int totalCount;
/**
* 構(gòu)造方法,只構(gòu)造空頁
*/
public Page() {
this(0, 0, DEFAULT_PAGE_SIZE, new ArrayList());
}
/**
* 默認構(gòu)造方法
*
* @param start
* 本頁數(shù)據(jù)在數(shù)據(jù)庫中的起始位置
* @param totalSize
* 數(shù)據(jù)庫中總記錄條數(shù)
* @param pageSize
* 本頁容量
* @param results
* 本頁包含的數(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ù)庫中包含的總記錄數(shù)
*/
public int getTotalCount() {
return this.totalCount;
}
/**
* 取總頁數(shù)
*/
public int getTotalPageCount() {
if (totalCount % pageSize == 0)
return totalCount / pageSize;
else
return totalCount / pageSize + 1;
}
/**
* 取每頁數(shù)據(jù)容量
*/
public int getPageSize() {
return pageSize;
}
/**
* 當前頁記錄
*/
public List getResults() {
return results;
}
/**
* 取當前頁碼,頁碼從1開始
*/
public int getCurrentPageNo() {
return start / pageSize + 1;
}
/**
* 是否有下一頁
*/
public boolean hasNextPage() {
return this.getCurrentPageNo() < this.getTotalPageCount() - 1;
}
/**
* 是否有上一頁
*/
public boolean hasPreviousPage() {
return this.getCurrentPageNo() > 1;
}
/**
* 獲取任一頁第一條數(shù)據(jù)的位置,每頁條數(shù)使用默認值
*/
protected static int getStartOfPage(int pageNo) {
return getStartOfPage(pageNo, DEFAULT_PAGE_SIZE);
}
/**
* 獲取任一頁第一條數(shù)據(jù)的位置,startIndex從0開始
*/
public static int getStartOfPage(int pageNo, int pageSize) {
return (pageNo - 1) * pageSize;
}
/**
* 設置總記錄數(shù)
*/
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
/**
* 設置記錄
* @param results
*/
public void setResults(List results) {
this.results = results;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
}
@佳佳
這個ModelAndView是Spring中的類,具體可以參考這里:
http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/servlet/ModelAndView.html也可以換成是Struts的實現(xiàn),這只是用在page和controller之間傳遞參數(shù)用的,和用request是一樣的。
@迷途羔羊
排序是要自己寫代碼實現(xiàn)的,所以叫 external paging嘛。
@fenix
就靈活性和可擴展性來說,eXtremeComponents更好一些。
@佳佳
你好,我是用的displaytag1.1,應該有這兩個屬性的,或者你重新下載個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
re: 運用ajax技術(shù)的樹型菜單 zJun's帛羅閣 2006-07-31 16:37
是怎么構(gòu)造樹的呢?是在tree_ajax.js和tree_htfl.js中嗎?哪里可以找到這兩個文件呢,這兩個文件所有的內(nèi)容就是文章中提供的js文件的內(nèi)容嗎?最好能提供這兩個文件的代碼。現(xià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();
}
不是很復雜啊,是題目還有什么要求沒有寫出來嗎?