org.springframework.context.MessageSource.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(102)

本文整理了Java中org.springframework.context.MessageSource.getMessage()方法的一些代码示例,展示了MessageSource.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MessageSource.getMessage()方法的具体详情如下:
包路径:org.springframework.context.MessageSource
类名称:MessageSource
方法名:getMessage

MessageSource.getMessage介绍

[英]Try to resolve the message. Return default message if no message was found.
[中]尝试解析该消息。如果没有找到消息,则返回默认消息。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the given Locale.
 * @param code code of the message
 * @param defaultMessage the String to return if the lookup fails
 * @param locale the Locale in which to do lookup
 * @return the message
 */
public String getMessage(String code, String defaultMessage, Locale locale) {
  String msg = this.messageSource.getMessage(code, null, defaultMessage, locale);
  return (msg != null ? msg : "");
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the given Locale.
 * @param code code of the message
 * @param locale the Locale in which to do lookup
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(String code, Locale locale) throws NoSuchMessageException {
  return this.messageSource.getMessage(code, null, locale);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance)
 * in the given Locale.
 * @param resolvable the MessageSourceResolvable
 * @param locale the Locale in which to do lookup
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
  return this.messageSource.getMessage(resolvable, locale);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the given Locale.
 * @param code code of the message
 * @param args arguments for the message, or {@code null} if none
 * @param locale the Locale in which to do lookup
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException {
  return this.messageSource.getMessage(code, args, locale);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the given Locale.
 * @param code code of the message
 * @param args arguments for the message, or {@code null} if none
 * @param defaultMessage the String to return if the lookup fails
 * @param locale the Locale in which to do lookup
 * @return the message
 */
public String getMessage(String code, @Nullable Object[] args, String defaultMessage, Locale locale) {
  String msg = this.messageSource.getMessage(code, args, defaultMessage, locale);
  return (msg != null ? msg : "");
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale) {
  return this.messageSource.getMessage(code, args, defaultMessage, locale);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException {
  if (this.parentMessageSource != null) {
    return this.parentMessageSource.getMessage(code, args, locale);
  }
  else {
    throw new NoSuchMessageException(code, locale);
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the default Locale.
 * @param code code of the message
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(String code) throws NoSuchMessageException {
  return this.messageSource.getMessage(code, null, getDefaultLocale());
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the default Locale.
 * @param code code of the message
 * @param args arguments for the message, or {@code null} if none
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(String code, @Nullable Object[] args) throws NoSuchMessageException {
  return this.messageSource.getMessage(code, args, getDefaultLocale());
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance).
 * @param resolvable the MessageSourceResolvable
 * @param htmlEscape if the message should be HTML-escaped
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(MessageSourceResolvable resolvable, boolean htmlEscape) throws NoSuchMessageException {
  String msg = this.messageSource.getMessage(resolvable, this.locale);
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance)
 * in the default Locale.
 * @param resolvable the MessageSourceResolvable
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(MessageSourceResolvable resolvable) throws NoSuchMessageException {
  return this.messageSource.getMessage(resolvable, getDefaultLocale());
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the default Locale.
 * @param code code of the message
 * @param defaultMessage the String to return if the lookup fails
 * @return the message
 */
public String getMessage(String code, String defaultMessage) {
  String msg = this.messageSource.getMessage(code, null, defaultMessage, getDefaultLocale());
  return (msg != null ? msg : "");
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code and the default Locale.
 * @param code code of the message
 * @param args arguments for the message, or {@code null} if none
 * @param defaultMessage the String to return if the lookup fails
 * @return the message
 */
public String getMessage(String code, @Nullable Object[] args, String defaultMessage) {
  String msg = this.messageSource.getMessage(code, args, defaultMessage, getDefaultLocale());
  return (msg != null ? msg : "");
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the message for the given code.
 * @param code code of the message
 * @param args arguments for the message, or {@code null} if none
 * @param htmlEscape if the message should be HTML-escaped
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getMessage(String code, @Nullable Object[] args, boolean htmlEscape) throws NoSuchMessageException {
  String msg = this.messageSource.getMessage(code, args, this.locale);
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException {
  return getMessageSource().getMessage(resolvable, locale);
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the theme message for the given code.
 * <p>Note that theme messages are never HTML-escaped, as they typically denote
 * theme-specific resource paths and not client-visible messages.
 * @param code code of the message
 * @param args arguments for the message as a List, or {@code null} if none
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getThemeMessage(String code, @Nullable List<?> args) throws NoSuchMessageException {
  return getTheme().getMessageSource().getMessage(code, (args != null ? args.toArray() : null), getLocale());
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the theme message for the given code.
 * <p>Note that theme messages are never HTML-escaped, as they typically denote
 * theme-specific resource paths and not client-visible messages.
 * @param code code of the message
 * @param args arguments for the message, or {@code null} if none
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getThemeMessage(String code, @Nullable Object[] args) throws NoSuchMessageException {
  return getTheme().getMessageSource().getMessage(code, args, getLocale());
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the given MessageSourceResolvable in the current theme.
 * <p>Note that theme messages are never HTML-escaped, as they typically denote
 * theme-specific resource paths and not client-visible messages.
 * @param resolvable the MessageSourceResolvable
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getThemeMessage(MessageSourceResolvable resolvable) throws NoSuchMessageException {
  return getTheme().getMessageSource().getMessage(resolvable, getLocale());
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the theme message for the given code.
 * <p>Note that theme messages are never HTML-escaped, as they typically denote
 * theme-specific resource paths and not client-visible messages.
 * @param code code of the message
 * @return the message
 * @throws org.springframework.context.NoSuchMessageException if not found
 */
public String getThemeMessage(String code) throws NoSuchMessageException {
  return getTheme().getMessageSource().getMessage(code, null, getLocale());
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Retrieve the theme message for the given code.
 * <p>Note that theme messages are never HTML-escaped, as they typically denote
 * theme-specific resource paths and not client-visible messages.
 * @param code code of the message
 * @param defaultMessage the String to return if the lookup fails
 * @return the message
 */
public String getThemeMessage(String code, String defaultMessage) {
  String msg = getTheme().getMessageSource().getMessage(code, null, defaultMessage, getLocale());
  return (msg != null ? msg : "");
}

相关文章

微信公众号

最新文章

更多

MessageSource类方法