Class SpringMessageResolver
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.MessageSourceAware,org.thymeleaf.messageresolver.IMessageResolver
Implementation of IMessageResolver that
integrates the standard Spring way of resolving messages into Thymeleaf.
Template-based resolution is done by means of using the available Spring-configured
MessageSource objects.
Origin-based resolution is done in exactly the same way as in StandardMessageResolver.
- Since:
- 3.0.3
- Author:
- Daniel Fernández
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateAbsentMessageRepresentation(org.thymeleaf.context.ITemplateContext context, Class<?> origin, String key, Object[] messageParameters) final org.springframework.context.MessageSourceReturns the message source (MessageSource) to be used for message resolution.final booleanReturns whether an exception will be raised when a message cannot be resolved and an absent message representation (like??key_locale??) would be returned instead.final StringresolveMessage(org.thymeleaf.context.ITemplateContext context, Class<?> origin, String key, Object[] messageParameters) final voidsetFailOnMissingMessage(boolean failOnMissingMessage) Sets whether an exception will be raised when a message cannot be resolved and an absent message representation (like??key_locale??) would be returned instead.final voidsetMessageSource(org.springframework.context.MessageSource messageSource) Sets the message source to be used for message resolutionMethods inherited from class org.thymeleaf.messageresolver.AbstractMessageResolver
getName, getOrder, setName, setOrder
-
Constructor Details
-
SpringMessageResolver
public SpringMessageResolver()
-
-
Method Details
-
getMessageSource
public final org.springframework.context.MessageSource getMessageSource()Returns the message source (
MessageSource) to be used for message resolution.- Returns:
- the message source
-
setMessageSource
public final void setMessageSource(org.springframework.context.MessageSource messageSource) Sets the message source to be used for message resolution
- Specified by:
setMessageSourcein interfaceorg.springframework.context.MessageSourceAware- Parameters:
messageSource- the message source
-
isFailOnMissingMessage
public final boolean isFailOnMissingMessage()Returns whether an exception will be raised when a message cannot be resolved and an absent message representation (like
??key_locale??) would be returned instead. Default isfalse.- Returns:
- whether missing messages raise an exception.
- Since:
- 3.1.7
-
setFailOnMissingMessage
public final void setFailOnMissingMessage(boolean failOnMissingMessage) Sets whether an exception will be raised when a message cannot be resolved and an absent message representation (like
??key_locale??) would be returned instead. Default isfalse.This applies to message expressions (
#{...}) and to the#messages.msg(...)family of methods, but not to the#messages.msgOrNull(...)family, which will still returnnullfor messages that cannot be resolved.- Parameters:
failOnMissingMessage- whether missing messages should raise an exception.- Since:
- 3.1.7
-
resolveMessage
public final String resolveMessage(org.thymeleaf.context.ITemplateContext context, Class<?> origin, String key, Object[] messageParameters) - Specified by:
resolveMessagein interfaceorg.thymeleaf.messageresolver.IMessageResolver
-
createAbsentMessageRepresentation
public String createAbsentMessageRepresentation(org.thymeleaf.context.ITemplateContext context, Class<?> origin, String key, Object[] messageParameters) - Specified by:
createAbsentMessageRepresentationin interfaceorg.thymeleaf.messageresolver.IMessageResolver
-