SPRING CONCEPTS

HTTP message conversion

Spring Concepts / HTTP message conversion

A message converter reads or writes HTTP bodies using a supported representation.

Understand the idea

Response-body methods return values to be written to the response instead of view names. A suitable converter can serialize products as JSON. RequestBody uses message conversion in the opposite direction. Returned type and media-type negotiation affect converter selection.

A concrete example

@RestController
class ProductApi { /* returns List<Product> */ }

In the application

See the independently runnable examples in Stage 28.

A JSON response does not need a Thymeleaf template.

See it in a working stage

Related concepts

Read the official documentation ↗
Java 21 · Spring Boot 4.1.1 · Edupoly