webwork 分页

一:Paging

package com.wmampr.common;

 

@SuppressWarnings("unused")

public class Paging {

      

       private int currentPage;//当前页

       private int pageSize = 5;//每页显示多少条

    private int totalSize;//总的记录数

    private int totalPage;//总的页数

       private boolean hasFirst;//首页

    private boolean hasPrevious;//判断有无上一页

    private boolean hasNext;//判断有无下一页

    private boolean hasLast;//最有一页

   

    public Paging(){

          

    }

   

    public Paging(int currentPage){

          

           this.currentPage = currentPage;

    }

   

    public Paging(int currentPage,int totalSize){  //有当前页能判断有无上下页 有总记录数能判断一共有多少页

          

           this.currentPage = currentPage;

        this.totalSize = totalSize;   

    }

   

   

       public int getCurrentPage() {

              return currentPage;

       }

       public void setCurrentPage(int currentPage) {

              this.currentPage = currentPage;

       }

       public boolean isHasFirst() {//是否是首页

             

              if(currentPage == 1)

                     return false;

              return true;

       }

       public void setHasFirst(boolean hasFirst) {

              this.hasFirst = hasFirst;

       }

       public boolean isHasLast() {//是否是最后一页

             

              if(currentPage == getTotalPage()||getTotalPage()==0)

                     return false;

              return true;

       }

       public void setHasLast(boolean hasLast) {

              this.hasLast = hasLast;

       }

       public boolean isHasNext() {//有无下一页

             

              if(isHasLast())

                     return true;

              return false;

       }

       public void setHasNext(boolean hasNext) {

              this.hasNext = hasNext;

       }

       public boolean isHasPrevious() {//有无前一页

             

              if(isHasFirst())

                     return true;

              return false;

       }

       public void setHasPrevious(boolean hasPrevious) {

              this.hasPrevious = hasPrevious;

       }

       public int getPageSize() {

              return pageSize;

       }

       public void setPageSize(int pageSize) {

              this.pageSize = pageSize;

       }

       public int getTotalPage() { //一共多少页

             

              totalPage = totalSize / pageSize;

              if(totalSize % pageSize != 0)

                     totalPage++;

              return totalPage;

       }

       public void setTotalPage(int totalPage) {

              this.totalPage = totalPage;

       }

       public int getTotalSize() {

              return totalSize;

       }

       public void setTotalSize(int totalSize) {

              this.totalSize = totalSize;

       }

}

二:Action

private int currentPage=1;

 

public int getCurrentPage() {

       return currentPage;

    }

 

    public void setCurrentPage(int currentPage) {

       this.currentPage = currentPage;

    }

 

public String getQy(){//查询所有招聘企业

              int countRow=qycxService.getCountRow();

              Paging page=new Paging(currentPage,countRow);

              if(currentPage>page.getTotalPage()){

                     currentPage=page.getTotalPage();

              }

              if(0==page.getTotalPage()){

                     currentPage=1;

              }

              page.setCurrentPage(currentPage);

              List qyList=qycxService.getQy(currentPage,page.getPageSize());

              Map request=(Map)ActionContext.getContext().get("request");

              request.put("qyList",qyList);

              request.put("page",page);

              return SUCCESS;

       }

 

三:页面

 

      <ww:set name="page" value="#request.page"/>

      <div align="right">

       <ww:if test="#page.hasFirst">

            <a href="MCgetTodayPrice.action?currentPage=1">首页</a>

       </ww:if>

       <ww:if test="#page.hasPrevious">

            <a href="MCgetTodayPrice.action?currentPage=<ww:property value="#page.currentPage-1"/>">上一页</a>

       </ww:if>

       <ww:if test="#page.hasNext">

            <a href="MCgetTodayPrice.action?currentPage=<ww:property value="#page.currentPage+1"/>">下一页</a>

       </ww:if>

       <ww:if test="#page.hasLast">

            <a href="MCgetTodayPrice.action?currentPage=<ww:property value="#page.totalPage"/>">尾页</a>

       </ww:if>

     

       <br/>

        当前第<FONT color="red"><ww:property value="#page.currentPage"/></FONT>,

        总共<FONT color="red"><ww:property value="#page.totalPage"/></FONT>. 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值