packagecom.paic.bics.core.mybatis.page;importjava.util.List;
@SuppressWarnings("serial")public class Pagination extends SimplePage implementsjava.io.Serializable,
Paginable {/*** 当前页的数据*/
private Listlist;publicPagination() {
}public Pagination(int pageNo, int pageSize, inttotalCount) {super(pageNo, pageSize, totalCount);
}
@SuppressWarnings("unchecked")public Pagination(int pageNo, int pageSize, inttotalCount, List list) {super(pageNo, pageSize, totalCount);this.list =list;
}public intgetFirstResult() {return (pageNo - 1) *pageSize;
}public ListgetList() {returnlist;
}public void setList(Listlist) {this.list =list;
}/**paic.bics SEO 翻页版本*/
publicString getWebPage(String page){
StringBuffer pageHtml= new StringBuffer("
- ");if(this.getPageNo()>1){if(this.getPageNo()>5){
pageHtml.append("
首页");}
pageHtml.append("
上一页");}for (int i = (this.getPageNo()-2<=0?1:this.getPageNo()-2),no = 1; i <= this.getTotalPage()&& no <6 ; i++,no++) {if (this.getPageNo() ==i) {
pageHtml.append("
"+i+"");}else{
pageHtml.append("
"+i+"");}
}if(this.getPageNo() < this.getTotalPage()){
pageHtml.append("
下一页");}
pageHtml.append("
");returnpageHtml.toString();}/**Ajxa翻页*/
publicString getSiAjaxPageHtml(){
StringBuffer pageHtml= new StringBuffer("
- ");if(this.getPageNo()>1){if(this.getPageNo()>5){
pageHtml.append("
首页");}
pageHtml.append("
上一页");}for (int i = (this.getPageNo()-2<=0?1:this.getPageNo()-2),no = 1; i <= this.getTotalPage()&& no <6 ; i++,no++) {if (this.getPageNo() ==i) {
pageHtml.append("
"+i+"");}else{
pageHtml.append("
"+i+"");}
}if(this.getPageNo() < this.getTotalPage()){
pageHtml.append("
下一页");}
pageHtml.append("
");returnpageHtml.toString();}/**普通翻页*/
publicString getPageHtml(){
StringBuffer pageHtml= new StringBuffer("
- ");if(this.getPageNo()>1){if(this.getPageNo()>5){
pageHtml.append("
首页");}
pageHtml.append("
上一页");}for (int i = (this.getPageNo()-2<=0?1:this.getPageNo()-2),no = 1; i <= this.getTotalPage()&& no <6 ; i++,no++) {if (this.getPageNo() ==i) {
pageHtml.append("
"+i+"");}else{
pageHtml.append("
"+i+"");}
}if(this.getPageNo() < this.getTotalPage()){
pageHtml.append("
下一页");}
pageHtml.append("
");pageHtml.append("
pageHtml.append(" function _submitform(pageNo){");
pageHtml.append(" $(\"#formId\").append($(\"\")).submit();");
pageHtml.append(" }");
pageHtml.append("");returnpageHtml.toString();
}
}
Pagination类实现与翻页功能
本文介绍了一个自定义Pagination类的实现,该类继承了SimplePage并实现了Paginable接口,用于处理分页逻辑。文章详细展示了如何计算每页显示的数据范围、获取当前页数据列表,并提供了三种不同场景下的翻页链接生成方法:适用于SEO优化的网页翻页、AJAX请求翻页及通用的普通翻页。
2718

被折叠的 条评论
为什么被折叠?



