Spring: Start Page Number from 1 with Pageable


Ordinary, Spring Pageable starts page number from zero. Here I introduce the way to begin page number with 1.

Environment

  • Spring 5
  • Spring Boot 2

How to Do

Add the following Configuration. I show Java and Kotlin code.

Java

Kotlin

Then, page number starts with 1.

Example

Kotlin code.

Then, we can get records on /sample. First 30 records will be gotten on /sample?page=1.

I show the service and the repository.