pagebreak.java~26~

来自「用户的注册 用户的登陆 发布用户的相关信息 浏览网站介绍的其他酒店的」· JAVA~26~ 代码 · 共 61 行

JAVA~26~
61
字号
package tool;

public class PageBreak {
    public PageBreak() {
    }

    /*******************************************
     * method name:count
     * method function :分页
     * return type:String
     * datetime : 2007-09-12
     *******************************************/

    public String count(int countRow, int page, String http) {
        int maxPage = 1; //最大页码
        if (countRow % 5 == 0) {
            maxPage = countRow / 5;
        } else {
            maxPage = countRow / 5 + 1;
        }
        int npage = 0; //当前页码
        int bpage = 0; //前一页码
        int lpage = 0; //后一页码
        if (page <= 1) {
            npage = 1;
            bpage = 1;
            lpage = 2;
        } else if (page >= maxPage) {
            npage = maxPage;
            bpage = maxPage - 1;
            lpage = maxPage;
        } else {
            npage = page;
            bpage = page - 1;
            lpage = page + 1;
        }
        if (maxPage == 0) {
            npage = 0;
        }
        String str = "<table width=100% border=0 cellspacing=0 cellpadding=0 ><tr><form id=form name=formto method=get action='" +
                     http + "'><td width=15% height=26 align= center><input type =hidden size=3 name =maxpage value=" +
                     maxPage + ">共有<font color= red >" +
                     countRow + "</font>记录</td>";
        str += "<td width = 25% height = 26 align =center > 当前页数:[ " + npage +
                " / <font color = 'red' >" + (maxPage-1) + " </font >]</td >";
        str += "<td width = 12% height = 26 align = center ><a href='" + http +
                "?page=1'>第一页 </a></td ><td width = 12% height = 26 align = center ><a href='" +
                http + "?page=" +
                bpage + "'> 上一页 </a></td>";
        str +=
                " <td width = 12% height = 26 align = center ><a href='" + http +
                "?page=" +
                lpage +
                "'>下一页</a> </td ><td width = 12% align = center > <a href='" +
                http + "?page=" +
                (maxPage-1) + "'>最后一页</a> </td></form></tr></table>";
        return str;
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?