View implementation that uses the FreeMarker template engine.
Depends on a single FreeMarkerConfig object such as
FreeMarkerConfigurer being accessible in the application context.
Alternatively the FreeMarker Configuration can be set directly on this
class via setConfiguration.
The url property is the location of the FreeMarker
template relative to the FreeMarkerConfigurer's
templateLoaderPath.
Note
Spring's FreeMarker support requires FreeMarker 2.3 or higher.
| Modifier and Type | Field and Description |
|---|---|
| private freemarker. | |
| private String | |
| private boolean | |
| public static final String | SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE
Attribute name of the |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Overrides org. Implements org. Invoked by the containing This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. |
| protected FreeMarkerConfig | Returns: theFreeMarkerConfig instance to use for this viewAutodetect a |
| public boolean | checkResourceExists(Locale
the desired Locale that we're looking for locale)Implements abstract org. Check that the FreeMarker template used for this view exists and is valid. |
| private Charset | |
| protected freemarker. | |
| protected String | |
| protected Mono | getModelAttributes(Map<String, ?> model, ServerWebExchange exchange)
Overrides org. Prepare the model to use for rendering by potentially exposing a
|
| protected freemarker. | getObjectWrapper()
Get the configured FreeMarker |
| protected freemarker. | Returns: the FreeMarker template to renderthe current locale locale)
Deprecated
for removal since 6.1. since 6.1, in favor of
lookupTemplate(Locale), to be
removed in 6.2
Get the FreeMarker template for the given locale, to be rendered by this view. |
| protected freemarker. | Returns: the FreeMarker template model, as aSimpleHash or subclass thereofthe model to use for rendering model, ServerWebExchange current exchange exchange)Build a FreeMarker template model for the given model map. |
| protected Mono | Returns: the FreeMarker template to renderthe current locale locale)Retrieve the FreeMarker template for the given locale, to be rendered by this view. |
| protected freemarker. | Returns: the FreeMarker configuration (nevernull)Obtain the FreeMarker |
| protected Mono | renderInternal(Map<String, Object>
combined output Map (never renderAttributes, MediaType null),
with dynamic values taking precedence over static attributesthe content type selected to render with, which should
match one of the supported media types contentType, ServerWebExchange current exchange exchange)Implements abstract org. Subclasses must implement this method to actually render the view. |
| public Mono | resourceExists(Locale
the desired Locale that we're looking for locale)Overrides org. Check that the FreeMarker template used for this view exists and is valid. |
| public void | setConfiguration(freemarker.
Set the FreeMarker |
| public void | |
| public void | setExposeSpringMacroHelpers(boolean exposeSpringMacroHelpers)
Set whether to expose a |
| configuration | back to summary |
|---|---|
| private freemarker. | |
| encoding | back to summary |
|---|---|
| private String encoding
| |
| exposeSpringMacroHelpers | back to summary |
|---|---|
| private boolean exposeSpringMacroHelpers | |
| SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE | back to summary |
|---|---|
| public static final String SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE Attribute name of the
| |
| FreeMarkerView | back to summary |
|---|---|
| public FreeMarkerView() | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() throws Exception Overrides org. Implements org. Doc from org. Invoked by the containing This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. | |
| autodetectConfiguration | back to summary |
|---|---|
| protected FreeMarkerConfig autodetectConfiguration() throws BeansException Autodetect a
| |
| checkResourceExists | back to summary |
|---|---|
| public boolean checkResourceExists(Locale locale) throws Exception Implements abstract org. Check that the FreeMarker template used for this view exists and is valid. Can be overridden to customize the behavior, for example in case of multiple templates to be rendered into a single view.
| |
| getCharset | back to summary |
|---|---|
| private Charset getCharset(MediaType mediaType) | |
| getConfiguration | back to summary |
|---|---|
| protected freemarker. Get the FreeMarker
| |
| getEncoding | back to summary |
|---|---|
| protected String getEncoding() Get the encoding for the FreeMarker template.
| |
| getModelAttributes | back to summary |
|---|---|
| protected Mono Overrides org. Prepare the model to use for rendering by potentially exposing a
| |
| getObjectWrapper | back to summary |
|---|---|
| protected freemarker. Get the configured FreeMarker | |
| getTemplate | back to summary |
|---|---|
| protected freemarker. Deprecated for removal since 6.1. since 6.1, in favor of Get the FreeMarker template for the given locale, to be rendered by this view. By default, the template specified by the "url" bean property will be retrieved.
| |
| getTemplateModel | back to summary |
|---|---|
| protected freemarker. Build a FreeMarker template model for the given model map. The default implementation builds a
| |
| lookupTemplate | back to summary |
|---|---|
| protected Mono Retrieve the FreeMarker template for the given locale, to be rendered by this view. By default, the template specified by the "url" bean property will be retrieved, and the returned mono will subscribe on the bounded elastic scheduler as template lookups can be blocking operations. | |
| obtainConfiguration | back to summary |
|---|---|
| protected freemarker. Obtain the FreeMarker
| |
| renderInternal | back to summary |
|---|---|
| protected Mono Implements abstract org. Doc from org. Subclasses must implement this method to actually render the view.
| |
| resourceExists | back to summary |
|---|---|
| public Mono Overrides org. Check that the FreeMarker template used for this view exists and is valid. Can be overridden to customize the behavior, for example in case of multiple templates to be rendered into a single view.
| |
| setConfiguration | back to summary |
|---|---|
| public void setConfiguration(freemarker. Set the FreeMarker Typically this property is not set directly. Instead a single
| |
| setEncoding | back to summary |
|---|---|
| public void setEncoding(String encoding) Set the encoding of the FreeMarker template file. By default | |
| setExposeSpringMacroHelpers | back to summary |
|---|---|
| public void setExposeSpringMacroHelpers(boolean exposeSpringMacroHelpers) Set whether to expose a Default is Needed for Spring's FreeMarker default macros. Note that this is not required for templates that use HTML forms unless you wish to take advantage of the Spring helper macros.
| |