liveBook · Manning

Page size

As explained in Spring in Action, Sixth Edition

A page size is the maximum number of results requested for one page of a paginated query.

A page size sets the maximum number of results requested for one page of a paginated query. Smaller pages keep long result lists manageable while still allowing clients to request more data when needed. section 6.2 section 7.2.2

Configuring an order-list page

An order controller can request the first page with a default page size of 20 by calling PageRequest.of(0, pageSize). Annotating the controller with @ConfigurationProperties(prefix="taco.orders") lets configuration replace that default: taco.orders.pageSize: 10 in application.yml or TACO_ORDERS_PAGESIZE=10 as an environment variable. Changing the value avoids rebuilding and redeploying the application. section 6.2

Pagination requests use the page size together with page and sorting controls:

  • Spring Data combines a Pageable with a repository query to select a page and its maximum result count. section 6.2
  • REST collection resources accept size in the request URL; page numbers are zero-based, so page=1 requests the second page. section 7.2.2
  • Sorting can accompany the size, such as requesting 12 newest tacos with sort=createdAt,desc&page=0&size=12. section 7.2.2

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains page size through repository integration, configuration, HTTP parameters, zero-based pages, and sorting.
Examples
Uses order lists, taco collection requests, YAML configuration, environment variables, and curl commands.
What it assumes
Uses Spring Data repositories, controllers, configuration properties, and HTTP requests as the surrounding implementation context.
What you can do after
Apply it via Spring Data Pageable or REST query parameters to limit returned results and select pages.
How it connects
Connects page size with pagination, Spring Data Pageable, configuration properties, REST APIs, and sorting.

Also explained in

Compare how 3 books explain page size →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.