Exposes the following JavaBean properties:
Depends on a single FreeMarkerConfig object such as FreeMarkerConfigurer
being accessible in the current web application context, with any bean name.
Alternatively, you can set the FreeMarker Configuration object as a
bean property. See setConfiguration for more details on the impacts
of this approach.
Note
Spring's FreeMarker support requires FreeMarker 2.3 or higher. As of Spring Framework 6.0, FreeMarker templates are rendered in a minimal fashion without JSP support, just exposing request attributes in addition to the MVC-provided model map for alignment with common Servlet resources.
setUrl, setExposeSpringMacroHelpers, setEncoding, setConfiguration, FreeMarkerConfig, FreeMarkerConfigurer
| Modifier and Type | Class and Description |
|---|---|
| private static class | FreeMarkerView.
Extension of FreeMarker |
| Modifier and Type | Field and Description |
|---|---|
| private freemarker. | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected FreeMarkerConfig | Returns: the Configuration instance to use for FreeMarkerViewsAutodetect a |
| protected freemarker. | Returns: the FreeMarker template model, as aSimpleHash or subclass thereofthe model to use for rendering model, HttpServletRequest current HTTP request request, HttpServletResponse current servlet response response)Build a FreeMarker template model for the given model Map. |
| public boolean | checkResource(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. |
| protected void | doRender(Map<String, Object>
the model to use for rendering model, HttpServletRequest current HTTP request request, HttpServletResponse current servlet response response)Render the FreeMarker view to the given response, using the given model map which contains the complete template model to use. |
| protected void | exposeHelpers(Map<String, Object>
the model that will be passed to the template at merge time model, HttpServletRequest current HTTP request request)Expose helpers unique to each rendering operation. |
| protected freemarker. | |
| protected String | |
| protected freemarker. | getObjectWrapper()
Return the configured FreeMarker |
| protected freemarker. | Returns: the FreeMarker template to renderthe current locale locale)Retrieve the FreeMarker template for the given locale, to be rendering by this view. |
| protected freemarker. | Returns: the FreeMarker templatethe file name of the desired template name, Locale the current locale locale)Retrieve the FreeMarker template specified by the given name, using the encoding specified by the "encoding" bean property. |
| protected void | initServletContext(ServletContext
the ServletContext that this application object runs in
(never servletContext)null)Overrides org. Invoked on startup. |
| protected freemarker. | Returns: the FreeMarker configuration (nevernull)Obtain the FreeMarker configuration for actual use. |
| protected void | processTemplate(freemarker.
the template to process template,the model for the template model,servlet response (use this to get the OutputStream or Writer) response)Process the FreeMarker template to the servlet response. |
| protected void | renderMergedTemplateModel(Map<String, Object>
combined output Map, with request attributes and
session attributes merged into it if required model, HttpServletRequest current HTTP request request, HttpServletResponse current HTTP response response)Implements abstract org. Process the model map by merging it with the FreeMarker template. |
| public void | setConfiguration(freemarker.
Set the FreeMarker Configuration to be used by this view. |
| public void |
| configuration | back to summary |
|---|---|
| private freemarker. | |
| encoding | back to summary |
|---|---|
| private String encoding
| |
| FreeMarkerView | back to summary |
|---|---|
| public FreeMarkerView() | |
| autodetectConfiguration | back to summary |
|---|---|
| protected FreeMarkerConfig autodetectConfiguration() throws BeansException Autodetect a
| |
| buildTemplateModel | back to summary |
|---|---|
| protected freemarker. Build a FreeMarker template model for the given model Map. The default implementation builds a
| |
| checkResource | back to summary |
|---|---|
| public boolean checkResource(Locale locale) throws Exception 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.
| |
| doRender | back to summary |
|---|---|
| protected void doRender(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception Render the FreeMarker view to the given response, using the given model map which contains the complete template model to use. The default implementation renders the template specified by the "url"
bean property, retrieved via Can be overridden to customize the behavior, for example to render multiple templates into a single view.
| |
| exposeHelpers | back to summary |
|---|---|
| protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request) throws Exception Expose helpers unique to each rendering operation. This is necessary so that different rendering operations can't overwrite each other's formats etc. Called by
| |
| getConfiguration | back to summary |
|---|---|
| protected freemarker. Return the FreeMarker configuration used by this view.
| |
| getEncoding | back to summary |
|---|---|
| protected String getEncoding() Return the encoding for the FreeMarker template.
| |
| getObjectWrapper | back to summary |
|---|---|
| protected freemarker. Return the configured FreeMarker | |
| getTemplate | back to summary |
|---|---|
| protected freemarker. Retrieve the FreeMarker template for the given locale, to be rendering by this view. By default, the template specified by the "url" bean property will be retrieved.
| |
| getTemplate | back to summary |
|---|---|
| protected freemarker. Retrieve the FreeMarker template specified by the given name, using the encoding specified by the "encoding" bean property. Can be called by subclasses to retrieve a specific template, for example to render multiple templates into a single view.
| |
| initServletContext | back to summary |
|---|---|
| protected void initServletContext(ServletContext servletContext) throws BeansException Overrides org. Invoked on startup. Looks for a single FreeMarkerConfig bean to find the relevant Configuration for this factory. Checks that the template for the default Locale can be found: FreeMarker will check non-Locale-specific templates if a locale-specific one is not found.
| |
| obtainConfiguration | back to summary |
|---|---|
| protected freemarker. Obtain the FreeMarker configuration for actual use.
| |
| processTemplate | back to summary |
|---|---|
| protected void processTemplate(freemarker. Process the FreeMarker template to the servlet response. Can be overridden to customize the behavior.
| |
| renderMergedTemplateModel | back to summary |
|---|---|
| protected void renderMergedTemplateModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception Implements abstract org. Process the model map by merging it with the FreeMarker template. Output is directed to the servlet response. This method can be overridden if custom behavior is needed.
| |
| setConfiguration | back to summary |
|---|---|
| public void setConfiguration(freemarker. Set the FreeMarker Configuration to be used by this view. If this is not set, the default lookup will occur: a single | |
| setEncoding | back to summary |
|---|---|
| public void setEncoding(String encoding) Set the encoding of the FreeMarker template file. Default is determined by the FreeMarker Configuration: "ISO-8859-1" if not specified otherwise. Specify the encoding in the FreeMarker Configuration rather than per template if all your templates share a common encoding. | |
SimpleHash, adding a fallback to request attributes.
Similar to the formerly used freemarker.ext.servlet.AllHttpScopesHashModel ,
just limited to common request attribute exposure.
| Modifier and Type | Field and Description |
|---|---|
| private final HttpServletRequest |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public freemarker. |
| request | back to summary |
|---|---|
| private final HttpServletRequest request | |
| RequestHashModel | back to summary |
|---|---|
| public RequestHashModel(freemarker. | |
| get | back to summary |
|---|---|
public freemarker.
| |