forked from maxliaops/Java_Web_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreatePage.java
More file actions
111 lines (98 loc) · 2.38 KB
/
CreatePage.java
File metadata and controls
111 lines (98 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.yxq.model;
public class CreatePage {
private int CurrentP; //当前页码
private int AllP; //总页数
private int AllR; //总记录数
private int PerR; //每页显示记录数
private String PageLink; //分页导航栏信息
private String PageInfo; //分页状态显示信息
public CreatePage(){
CurrentP=1;
AllP=1;
AllR=0;
PerR=3;
PageLink="";
PageInfo="";
}
/** 设置每页显示记录数 */
public void setPerR(int PerR){
this.PerR=PerR;
}
/** 设置总记录数 */
public void setAllR(int AllR){
this.AllR=AllR;
}
/** 计算总页数 */
public void setAllP(){
AllP=(AllR%PerR==0)?(AllR/PerR):(AllR/PerR+1);
}
/** 设置当前页码 */
public void setCurrentP(String currentP) {
if(currentP==null||currentP.equals(""))
currentP="1";
try{
CurrentP=Integer.parseInt(currentP);
}catch(NumberFormatException e){
CurrentP=1;
e.printStackTrace();
}
if(CurrentP<1)
CurrentP=1;
if(CurrentP>AllP)
CurrentP=AllP;
}
/** 设置分页状态显示信息 */
public void setPageInfo(){
if(AllP>1){
PageInfo="<table border='0' cellpadding='3'><tr><td>";
PageInfo+="每页显示:"+PerR+"/"+AllR+" 条记录!";
PageInfo+="当前页:"+CurrentP+"/"+AllP+" 页!";
PageInfo+="</td></tr></table>";
}
}
/** 设置分页导航栏信息 */
public void setPageLink(String gowhich){
if(gowhich==null)
gowhich="";
if(gowhich.indexOf("?")>=0)
gowhich+="&";
else
gowhich+="?";
if(AllP>1){
PageLink="<table border='0' cellpadding='3'><tr><td>";
if(CurrentP>1){
PageLink+="<a href='"+gowhich+"showpage=1'>首页</a> ";
PageLink+="<a href='"+gowhich+"showpage="+(CurrentP-1)+"'>上一页</a> ";
}
if(CurrentP<AllP){
PageLink+="<a href='"+gowhich+"showpage="+(CurrentP+1)+"'>下一页</a> ";
PageLink+="<a href='"+gowhich+"showpage="+AllP+"'>尾页</a>";
}
PageLink+="</td></tr></table>";
}
}
/** 返回每页记录数 */
public int getPerR(){
return PerR;
}
/** 返回总记录数 */
public int getAllR() {
return AllR;
}
/** 返回总页数 */
public int getAllP() {
return AllP;
}
/** 返回当前页码 */
public int getCurrentP() {
return CurrentP;
}
/** 返回分页状态显示信息 */
public String getPageInfo(){
return PageInfo;
}
/** 返回分页导航栏信息 */
public String getPageLink(){
return PageLink;
}
}