코배웹_페이징처리

P.306
PageDTO

package org.zerock.domain;

import lombok.Data;

@Data
public class PageDTO {
	private int startPage, endPage, total;
	private boolean prev, next;
	private Criteria cri;
	
	public PageDTO(Criteria cri, int total) {
			this.cir = cri;
		this.total = total;

		this.endPage = (int) (Math.ceil(cri.getPageNum() / 10.0)) * 10;
		this.startPage = endPage - 9;

		this.prev = this.startPage > 1;

		int realEnd = (int) (Math.ceil(total * 1.0) / cri.getAmount());

		this.endPage = realEnd <= endPage ? realEnd : endPage;

		this.next = this.endPage < realEnd;
	}
	
	
}
 

Criteria

package org.zerock.domain;

import lombok.Data;

@Data
public class Criteria {
	private int pageNum, amount;

	public Criteria() {
		this(1, 10);
	}

	public Criteria(int pageNum, int amount) {
		this.pageNum = pageNum;
		this.amount = amount;
	}
}

좋은 웹페이지 즐겨찾기