类 DelegatingMessageSource
- java.lang.Object
- org.springframework.context.support.MessageSourceSupport
- org.springframework.context.support.DelegatingMessageSource
- 所有已实现的接口:
HierarchicalMessageSource
,MessageSource
public class DelegatingMessageSource extends MessageSourceSupport implements HierarchicalMessageSource
EmptyMessageSource
that delegates all calls to the parent MessageSource. If no parent is available, it simply won't resolve any message.Used as placeholder by AbstractApplicationContext, if the context doesn't define its own MessageSource. Not intended for direct use in applications.
- 从以下版本开始:
- 1.1.5
- 作者:
- Juergen Hoeller
- 另请参阅:
AbstractApplicationContext
字段概要
从类继承的字段 org.springframework.context.support.MessageSourceSupport
logger
构造器概要
构造器 构造器 说明 DelegatingMessageSource()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 String
getMessage(String code, Object[] args, String defaultMessage, Locale locale)
Try to resolve the message.String
getMessage(String code, Object[] args, Locale locale)
Try to resolve the message.String
getMessage(MessageSourceResolvable resolvable, Locale locale)
Try to resolve the message using all the attributes contained within theMessageSourceResolvable
argument that was passed in.MessageSource
getParentMessageSource()
Return the parent of this MessageSource, ornull
if none.void
setParentMessageSource(MessageSource parent)
Set the parent that will be used to try to resolve messages that this object can't resolve.从类继承的方法 org.springframework.context.support.MessageSourceSupport
createMessageFormat, formatMessage, isAlwaysUseMessageFormat, renderDefaultMessage, resolveArguments, setAlwaysUseMessageFormat
构造器详细资料
DelegatingMessageSource
public DelegatingMessageSource()
方法详细资料
setParentMessageSource
public void setParentMessageSource(MessageSource parent)
从接口复制的说明:HierarchicalMessageSource
Set the parent that will be used to try to resolve messages that this object can't resolve.- 指定者:
setParentMessageSource
在接口中HierarchicalMessageSource
- 参数:
parent
- the parent MessageSource that will be used to resolve messages that this object can't resolve. May benull
, in which case no further resolution is possible.
getParentMessageSource
public MessageSource getParentMessageSource()
从接口复制的说明:HierarchicalMessageSource
Return the parent of this MessageSource, ornull
if none.
getMessage
public String getMessage(String code, Object[] args, String defaultMessage, Locale locale)
从接口复制的说明:MessageSource
Try to resolve the message. Return default message if no message was found.- 指定者:
getMessage
在接口中MessageSource
- 参数:
code
- the message code to look up, e.g. 'calculator.noRateSet'. MessageSource users are encouraged to base message names on qualified class or package names, avoiding potential conflicts and ensuring maximum clarity.args
- an array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), ornull
if nonedefaultMessage
- a default message to return if the lookup failslocale
- the locale in which to do the lookup- 返回:
- the resolved message if the lookup was successful, otherwise the default message passed as a parameter (which may be
null
) - 另请参阅:
MessageSource.getMessage(MessageSourceResolvable, Locale)
,MessageFormat
getMessage
public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException
从接口复制的说明:MessageSource
Try to resolve the message. Treat as an error if the message can't be found.- 指定者:
getMessage
在接口中MessageSource
- 参数:
code
- the message code to look up, e.g. 'calculator.noRateSet'. MessageSource users are encouraged to base message names on qualified class or package names, avoiding potential conflicts and ensuring maximum clarity.args
- an array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), ornull
if nonelocale
- the locale in which to do the lookup- 返回:
- the resolved message (never
null
) - 抛出:
NoSuchMessageException
- if no corresponding message was found- 另请参阅:
MessageSource.getMessage(MessageSourceResolvable, Locale)
,MessageFormat
getMessage
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException
从接口复制的说明:MessageSource
Try to resolve the message using all the attributes contained within theMessageSourceResolvable
argument that was passed in.NOTE: We must throw a
NoSuchMessageException
on this method since at the time of calling this method we aren't able to determine if thedefaultMessage
property of the resolvable isnull
or not.- 指定者:
getMessage
在接口中MessageSource
- 参数:
resolvable
- the value object storing attributes required to resolve a message (may include a default message)locale
- the locale in which to do the lookup- 返回:
- the resolved message (never
null
since even aMessageSourceResolvable
-provided default message needs to be non-null) - 抛出:
NoSuchMessageException
- if no corresponding message was found (and no default message was provided by theMessageSourceResolvable
)- 另请参阅:
MessageSourceResolvable.getCodes()
,MessageSourceResolvable.getArguments()
,MessageSourceResolvable.getDefaultMessage()
,MessageFormat