diff --git a/hutool-core/src/main/java/cn/hutool/core/util/PageUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/PageUtil.java index 6fcb73bce..425b6f3d7 100644 --- a/hutool-core/src/main/java/cn/hutool/core/util/PageUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/util/PageUtil.java @@ -175,10 +175,21 @@ public class PageUtil { * @return 总页数 */ public static int totalPage(int totalCount, int pageSize) { + return totalPage((long) totalCount,pageSize); + } + + /** + * 根据总数计算总页数 + * + * @param totalCount 总数 + * @param pageSize 每页数 + * @return 总页数 + */ + public static int totalPage(long totalCount, int pageSize) { if (pageSize == 0) { return 0; } - return totalCount % pageSize == 0 ? (totalCount / pageSize) : (totalCount / pageSize + 1); + return Math.toIntExact(totalCount % pageSize == 0 ? (totalCount / pageSize) : (totalCount / pageSize + 1)); } /**