liveBook · Manning

Servlet request attribute

As explained in Spring in Action, Sixth Edition

A request attribute is a named value associated with an individual web request and made available to request-processing components or view rendering.

A servlet request attribute is a named value attached to one web request. In Spring MVC, model data is copied into request attributes before a view renders, giving Thymeleaf access to controller-provided values. section 2.1.3

Rendering a message

A request attribute named "message" can supply the text of a paragraph. Thymeleaf uses th:text with ${message} to replace the element body with that value. section 2.1.3

Rendering a collection

A request attribute named "wrap" can hold ingredients for a taco form. Thymeleaf uses th:each to render one element for every ingredient and exposes each item as a template variable. section 2.1.3

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains copying model data, reading values, and iterating collections, without detailing servlet internals.
Examples
Uses a message paragraph and a taco ingredient collection rendered with Thymeleaf expressions.
What it assumes
Assumes basic Spring MVC model and view terminology while defining how templates access controller-provided data.
What you can do after
Apply it via Thymeleaf by reading named values and repeating markup for collection-valued attributes.
How it connects
Links servlet request attributes with Spring MVC, models, controllers, views, and Thymeleaf templates.

Also explained in

Compare how 2 books explain servlet request attribute →

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.