public class SpringTemplateEngine
extends org.thymeleaf.TemplateEngine
implements org.springframework.context.MessageSourceAware, org.springframework.beans.factory.InitializingBean
Implementation of ITemplateEngine
meant for Spring MVC applications,
that establishes by default an instance of SpringStandardDialect
as a dialect (instead of an instance of StandardDialect
.
It also configures a SpringMessageResolver
as message resolver, and
implements the MessageSourceAware
interface in order to let Spring
automatically setting the MessageSource
used at the application
(bean needs to have id "messageSource"). If this Spring standard setting
needs to be overridden, the setTemplateEngineMessageSource(MessageSource)
can
be used.
Constructor and Description |
---|
SpringTemplateEngine() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
boolean |
getEnableSpringELCompiler()
Returns whether the SpringEL compiler should be enabled in SpringEL expressions or not.
|
void |
setEnableSpringELCompiler(boolean enableSpringELCompiler)
Sets whether the SpringEL compiler should be enabled in SpringEL expressions or not.
|
void |
setMessageSource(org.springframework.context.MessageSource messageSource)
Implementation of the
MessageSourceAware.setMessageSource(MessageSource)
method at the MessageSourceAware interface, provided so that
Spring is able to automatically set the currently configured MessageSource into
this template engine. |
void |
setTemplateEngineMessageSource(org.springframework.context.MessageSource templateEngineMessageSource)
Convenience method for setting the message source that will
be used by this template engine, overriding the one automatically set by
Spring at the
setMessageSource(MessageSource) method. |
addDialect, addDialect, addLinkBuilder, addMessageResolver, addTemplateResolver, clearDialects, clearTemplateCache, clearTemplateCacheFor, getCacheManager, getConfiguration, getDecoupledTemplateLogicResolver, getDialects, getDialectsByPrefix, getEngineContextFactory, getLinkBuilders, getMessageResolvers, getTemplateResolvers, initializeSpecific, isInitialized, process, process, process, process, process, process, processThrottled, processThrottled, processThrottled, setAdditionalDialects, setCacheManager, setDecoupledTemplateLogicResolver, setDialect, setDialects, setDialectsByPrefix, setEngineContextFactory, setLinkBuilder, setLinkBuilders, setMessageResolver, setMessageResolvers, setTemplateResolver, setTemplateResolvers, threadIndex
public void setMessageSource(org.springframework.context.MessageSource messageSource)
Implementation of the MessageSourceAware.setMessageSource(MessageSource)
method at the MessageSourceAware
interface, provided so that
Spring is able to automatically set the currently configured MessageSource
into
this template engine.
If several MessageSource
implementation beans exist, Spring will inject here
the one with id "messageSource".
This property should not be set manually in most scenarios (see
setTemplateEngineMessageSource(MessageSource)
instead).
setMessageSource
in interface org.springframework.context.MessageSourceAware
messageSource
- the message source to be used by the message resolverpublic void setTemplateEngineMessageSource(org.springframework.context.MessageSource templateEngineMessageSource)
Convenience method for setting the message source that will
be used by this template engine, overriding the one automatically set by
Spring at the setMessageSource(MessageSource)
method.
templateEngineMessageSource
- the message source to be used by the message resolverpublic boolean getEnableSpringELCompiler()
Returns whether the SpringEL compiler should be enabled in SpringEL expressions or not.
(This is just a convenience method, equivalent to calling
SpringStandardDialect.getEnableSpringELCompiler()
on the dialect instance itself. It is provided
here in order to allow users to enable the SpEL compiler without
having to directly create instances of the SpringStandardDialect
)
Expression compilation can significantly improve the performance of Spring EL expressions, but might not be adequate for every environment. Read the official Spring documentation for more detail.
Also note that although Spring includes a SpEL compiler since Spring 4.1, most expressions in Thymeleaf templates will only be able to properly benefit from this compilation step when at least Spring Framework version 4.2.4 is used.
This flag is set to false by default.
public void setEnableSpringELCompiler(boolean enableSpringELCompiler)
Sets whether the SpringEL compiler should be enabled in SpringEL expressions or not.
(This is just a convenience method, equivalent to calling
SpringStandardDialect.setEnableSpringELCompiler(boolean)
on the dialect instance itself. It is provided
here in order to allow users to enable the SpEL compiler without
having to directly create instances of the SpringStandardDialect
)
Expression compilation can significantly improve the performance of Spring EL expressions, but might not be adequate for every environment. Read the official Spring documentation for more detail.
Also note that although Spring includes a SpEL compiler since Spring 4.1, most expressions in Thymeleaf templates will only be able to properly benefit from this compilation step when at least Spring Framework version 4.2.4 is used.
This flag is set to false by default.
enableSpringELCompiler
- true if SpEL expressions should be compiled if possible, false if not.Copyright © 2016 The THYMELEAF team. All rights reserved.