Interface FragmentsRendering
Public API to render HTML fragments. A fragment is a portion of an HTML page.
 Normally HTML is rendered with a single model and view. This API allows
 using multiple model and view pairs, one for each HTML fragment.
 
For use with frontends technologies such as htmx where multiple page fragments may be rendered in one response.
Supported as a return value from controller methods.
- Since:
- 6.2
- Author:
- Rossen Stoyanchev
- 
Nested Class SummaryNested Classes
- 
Field SummaryFields inherited from interface org.springframework.web.servlet.ViewPATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
- 
Method SummaryModifier and TypeMethodDescriptionstatic FragmentsRendering.BuilderCreate a builder with one HTML fragment, also inheriting attributes from the shared model for the request.static FragmentsRendering.BuilderCreate a builder with one HTML fragment.static FragmentsRendering.Builderfragments(Collection<ModelAndView> fragments) Create a builder with multiple HTML fragments.headers()Return headers to add to the response.status()Return the HTTP status to set the response to.Methods inherited from interface org.springframework.web.servlet.SmartViewisRedirectView, resolveNestedViewsMethods inherited from interface org.springframework.web.servlet.ViewgetContentType, render
- 
Method Details- 
status@Nullable HttpStatusCode status()Return the HTTP status to set the response to.
- 
headersHttpHeaders headers()Return headers to add to the response.
- 
fragmentCreate a builder with one HTML fragment, also inheriting attributes from the shared model for the request.- Parameters:
- viewName- the name of the view for the fragment
- Returns:
- the created builder
- Since:
- 6.2.1
 
- 
fragmentCreate a builder with one HTML fragment.- Parameters:
- viewName- the view name for the fragment
- model- attributes for the fragment, in addition to attributes from the shared model for the request
- Returns:
- the created builder
- Since:
- 6.2.1
 
- 
fragmentsCreate a builder with multiple HTML fragments.- Parameters:
- fragments- the fragments to add; each fragment also inherits attributes from the shared model for the request
- Returns:
- the created builder
- Since:
- 6.2.1
 
 
-