<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/spring-boot-build-url-shortener-application---part-9-spring-data-jpa-pagination-jaufm9u63" -->

---
title: Spring Boot: Build URL Shortener Application - Part 9:...
description: A hands-on walkthrough builds pagination into a Spring Boot URL shortener application using Spring Data JPA&#x27;s Pageable and Page APIs. It covers converting...
canonical: https://daily.dev/posts/spring-boot-build-url-shortener-application---part-9-spring-data-jpa-pagination-jaufm9u63
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Spring Boot: Build URL Shortener Application - Part 9: Spring Data JPA Pagination | daily.dev
og:description: A hands-on walkthrough builds pagination into a Spring Boot URL shortener application using Spring Data JPA&#x27;s Pageable and Page APIs. It covers converting...
og:url: https://daily.dev/posts/spring-boot-build-url-shortener-application---part-9-spring-data-jpa-pagination-jaufm9u63
og:image: https://api.daily.dev/og/posts/jaUfm9U63.png
og:image:alt: Spring Boot: Build URL Shortener Application - Part 9: Spring Data JPA Pagination
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Spring Boot: Build URL Shortener Application - Part 9: Spring Data JPA Pagination

**[SivaLabs \(YouTube\)](https://daily.dev/sources/sivalabs-youtube)** · 31 min read · 0 upvotes · 0 comments

## Summary

A hands-on walkthrough builds pagination into a Spring Boot URL shortener application using Spring Data JPA's Pageable and Page APIs. It covers converting Spring's zero-based page numbers to user-facing one-based numbers, creating a custom PageResult wrapper, building a reusable Thymeleaf pagination fragment with first/previous/next/last buttons, and comparing manual Pageable construction versus Spring Data's automatic web parameter binding (including the pageable one-indexed-parameters property and its limitations).

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=DgkFdiIVyKA>

## Questions this post answers

### Why does Spring Data JPA return page number 0 for the first page even after setting spring.data.web.pageable.one-indexed-parameters to true?

That property only affects incoming request parameters, converting a requested page=1 into the correct zero-indexed query, but the returned Page object still reports its page number as zero-based internally. So the first page always shows getNumber() as 0 regardless of that setting, meaning developers must still manually add 1 when displaying the page number to users.

_Developers wiring up pagination UI can compare this quirk against other Spring Data JPA solutions on daily.dev._

### Should I use Spring Data JPA's Pageable argument directly in my Spring MVC controller or build it manually in the service layer?

Building Pageable manually in the service layer is preferable when you want to keep your web layer decoupled from the persistence framework, since binding Pageable directly in the controller ties your API to Spring Data JPA and breaks if you switch to Spring JDBC or another ORM. The tradeoff is more boilerplate code versus Spring's automatic request parameter binding for page, size, and sort.

_Weighing coupling tradeoffs like this is easier when comparing architecture patterns on daily.dev._

## Similar posts on daily.dev

- [Offset and Keyset Pagination with Spring Data JPA](https://daily.dev/posts/offset-and-keyset-pagination-with-spring-data-jpa-nya5hmupa) · Jakarta EE · 0 upvotes · 0 comments

---

Tags: [#java](https://daily.dev/tags/java), [#spring](https://daily.dev/tags/spring), [#spring-boot](https://daily.dev/tags/spring-boot)

[View this post on daily.dev](https://daily.dev/posts/spring-boot-build-url-shortener-application---part-9-spring-data-jpa-pagination-jaufm9u63)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Spring Boot: Build URL Shortener Application - Part 9: Spring Data JPA Pagination","url":"https://daily.dev/posts/spring-boot-build-url-shortener-application---part-9-spring-data-jpa-pagination-jaufm9u63","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/spring-boot-build-url-shortener-application---part-9-spring-data-jpa-pagination-jaufm9u63"},"datePublished":"2026-09-27T07:26:37.659Z","dateModified":"2026-09-27T07:53:33.741Z","description":"A hands-on walkthrough builds pagination into a Spring Boot URL shortener application using Spring Data JPA's Pageable and Page APIs. It covers converting...","image":"https://i.ytimg.com/vi/DgkFdiIVyKA/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/DgkFdiIVyKA/sddefault.jpg","isAccessibleForFree":true,"articleSection":"SivaLabs (YouTube)","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"SivaLabs (YouTube)","logo":"https://media.daily.dev/image/upload/s--8ATVo4an--/f_auto,q_auto/v1790493987/logos/sivalabs-youtube?_a=BAMAMicg0","url":"https://daily.dev/sources/sivalabs-youtube"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/spring-boot-build-url-shortener-application---part-9-spring-data-jpa-pagination-jaufm9u63","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"java,spring,spring-boot","timeRequired":"PT31M","video":{"@type":"VideoObject","name":"Spring Boot: Build URL Shortener Application - Part 9: Spring Data JPA Pagination","description":"A hands-on walkthrough builds pagination into a Spring Boot URL shortener application using Spring Data JPA's Pageable and Page APIs. It covers converting...","thumbnailUrl":"https://i.ytimg.com/vi/DgkFdiIVyKA/sddefault.jpg","uploadDate":"2026-09-27T07:26:37.659Z","duration":"PT31M","url":"https://api.daily.dev/r/jaUfm9U63","embedUrl":"https://www.youtube.com/embed/DgkFdiIVyKA"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"SivaLabs (YouTube)","item":"https://daily.dev/sources/sivalabs-youtube"},{"@type":"ListItem","position":3,"name":"Spring Boot: Build URL Shortener Application - Part 9: Spring Data JPA Pagination"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/spring-boot-build-url-shortener-application---part-9-spring-data-jpa-pagination-jaufm9u63#faq","mainEntity":[{"@type":"Question","name":"Why does Spring Data JPA return page number 0 for the first page even after setting spring.data.web.pageable.one-indexed-parameters to true?","acceptedAnswer":{"@type":"Answer","text":"That property only affects incoming request parameters, converting a requested page=1 into the correct zero-indexed query, but the returned Page object still reports its page number as zero-based internally. So the first page always shows getNumber() as 0 regardless of that setting, meaning developers must still manually add 1 when displaying the page number to users. Developers wiring up pagination UI can compare this quirk against other Spring Data JPA solutions on daily.dev."}},{"@type":"Question","name":"Should I use Spring Data JPA's Pageable argument directly in my Spring MVC controller or build it manually in the service layer?","acceptedAnswer":{"@type":"Answer","text":"Building Pageable manually in the service layer is preferable when you want to keep your web layer decoupled from the persistence framework, since binding Pageable directly in the controller ties your API to Spring Data JPA and breaks if you switch to Spring JDBC or another ORM. The tradeoff is more boilerplate code versus Spring's automatic request parameter binding for page, size, and sort. Weighing coupling tradeoffs like this is easier when comparing architecture patterns on daily.dev."}}]}
```

