Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ts.utils; import java.util.HashMap; import java.util.Map; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; /** * * @author njanma */ public class PageUtil { public static Pageable createCurrentPageable(int page, int pageSize) { return new PageRequest(page, pageSize); } public static Map<String, Integer> pageNavigation(Page<?> page, Pageable pageable) { Map<String, Integer> attributes = new HashMap<>(); attributes.put("pageTotal", page.getTotalPages() - 1); attributes.put("pageNext", pageable.getPageNumber() + 1); attributes.put("pageBack", pageable.getPageNumber() - 1); attributes.put("activePage", page.getNumber()); return attributes; } public class MyPage { int currentPage, pageSize; } }