扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:中国IT实验室 来源:中国IT实验室 2007年9月24日
关键字:
在本页阅读全文(共2页)
2.分页逻辑方法代码节选:
public void setPageInfo(PaginationInfo paginationInfo) {
//跳转页
if (paginationInfo.getJumpState() == 1) { //首页
paginationInfo.setCurrentPageNumber(1);
}
if (paginationInfo.getJumpState() == 2) {
paginationInfo.setCurrentPageNumber(paginationInfo.getCurrentPageNumber() -
1);
}
if (paginationInfo.getJumpState() == 3) {
paginationInfo.setCurrentPageNumber(paginationInfo.getCurrentPageNumber() +
1);
}
if (paginationInfo.getJumpState() == 4) {
paginationInfo.setCurrentPageNumber(paginationInfo.getTotalPage());
}
int totalPage = total / paginationInfo.getPageSize();
if (total % paginationInfo.getPageSize() > 0) {
paginationInfo.setTotalPage(totalPage + 1);
}
else {
paginationInfo.setTotalPage(totalPage);
}
if (paginationInfo.getCurrentPageNumber() <= 1) {
paginationInfo.setCurrentPageNumber(1);
paginationInfo.setHasPrevious(false);
paginationInfo.setHasNext(true);
}
else if (paginationInfo.getCurrentPageNumber() >=
paginationInfo.getTotalPage()) {
paginationInfo.setCurrentPageNumber(paginationInfo.getTotalPage());
paginationInfo.setHasNext(false);
paginationInfo.setHasPrevious(true);
}
else {
paginationInfo.setHasPrevious(true);
paginationInfo.setHasNext(true);
}
}
3。jsp页面的分页显示代码节选:
<logic:equal name="testForm" property="paginationInfo.currentPageNumber" value="1">
<td align="right" width="30" height="22"><img src="images/pages/distop.gif" alt="首页" border="0"></td>
<td align="right" width="30" height="22"><img src="images/pages/disprevious.gif" alt="上一页" border="0" ></td>
</logic:equal>
<logic:greaterThan name="testForm" property="paginationInfo.currentPageNumber" value="1">
<td align="right" width="30" height="22"><a href="javascript:gotoPage(1)"><img src="images/pages/top.gif" alt="首页" border="0" ></a></td>
<td align="right" width="30" height="22"><a href="javascript:gotoPage(2)"><img src="images/pages/previous.gif" alt="上一页" border="0"></a></td>
</logic:greaterThan>
<logic:equal name="testForm" property="paginationInfo.hasNext" value="false">
<td align="right" width="30" height="22"><img src="images/pages/disnext.gif" alt="下一页" border="0" ></td>
<td align="right" width="30" height="22"><img src="images/pages/disbottom.gif" alt="末页" border="0" ></td>
</logic:equal>
<logic:equal name="testForm" property="paginationInfo.hasNext" value="true">
<td align="right" width="30" height="22"><a href="javascript:gotoPage(3)"><img src="images/pages/next.gif" alt="下一页" border="0" ></a></td>
<td align="right" width="30" height="22"><a href="javascript:gotoPage(4)"><img src="images/pages/bottom.gif" alt="末页" border="0"></a></td>
</logic:equal>
<html:hidden name="testForm" property="paginationInfo.jumpState">
...//省略
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者