Skip to content

Instantly share code, notes, and snippets.

@WalterInSH
Last active November 27, 2020 23:01
Show Gist options
  • Save WalterInSH/8909951 to your computer and use it in GitHub Desktop.
Save WalterInSH/8909951 to your computer and use it in GitHub Desktop.
pagination
import org.codehaus.jackson.annotate.JsonIgnore;
/**
* User: walter
* Date: 12/8/13
* Time: 10:53 AM
*/
public class Pagination {
// 每页显示数量
private int offset = 15;
// 总数
private int quantity;
// 当前页
private int currentPage = 1;
@JsonIgnore
public int getStart() {
if(currentPage <= 1){
return 0;
}
return (currentPage- 1) * offset -1;
}
public void setStart(){
}
public int getOffset() {
return offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getTotalPage() {
int totalPage;
if(quantity <= 0){
return 0;
}
totalPage = quantity/offset;
if(quantity % offset > 0){
return totalPage + 1;
}else{
return totalPage;
}
}
public void setTotalPage(int totalPage){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment