Java Mysql分页显示

public class View { 
    private int currentPage; 
    private int pageSize; 
    private int recordCount;

    public View(int pageSize, int recordCount, int currentPage) { 

        this.pageSize = pageSize; 

        this.recordCount = recordCount; 

        this.setCurrentPage(currentPage); 

    } 
    public int getPageCount() { 

        int size = recordCount / pageSize; 

        int flag = recordCount % pageSize; 

        if (flag != 0) { 

            size++; 

        } 
        if (recordCount == 0) {
            return 1; 

        } 
        return size; 

    } 

    public int getFromIndex() { 

        return (currentPage - 1) * pageSize;

    } 

    public void setCurrentPage(int currentPage) { 

        int vaildPage = currentPage <= 0 ? 1 : currentPage; 

        vaildPage = vaildPage > this.getPageCount() ? this.getPageCount() 

                : vaildPage; 

        this.currentPage = vaildPage; 

    } 

    public int getCurrentPage() { 

        return currentPage; 

    } 

    public int getPageSize() { 

        return pageSize; 

    }  
}