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

x33g5p2x  于2022-02-02 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(120)

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

WebApplicationContext.getMessage介绍

暂无

代码示例

代码示例来源: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.webApplicationContext.getMessage(code, args, getLocale());
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : 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 defaultMessage the String to return if the lookup fails
 * @param htmlEscape if the message should be HTML-escaped
 * @return the message
 */
public String getMessage(String code, @Nullable Object[] args, String defaultMessage, boolean htmlEscape) {
  String msg = this.webApplicationContext.getMessage(code, args, defaultMessage, getLocale());
  if (msg == null) {
    return "";
  }
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
}

代码示例来源: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.webApplicationContext.getMessage(resolvable, getLocale());
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
}

代码示例来源:origin: org.springframework/spring-webmvc

/**
 * 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.webApplicationContext.getMessage(code, args, getLocale());
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
}

代码示例来源:origin: org.springframework/spring-webmvc

/**
 * 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 defaultMessage the String to return if the lookup fails
 * @param htmlEscape if the message should be HTML-escaped
 * @return the message
 */
public String getMessage(String code, @Nullable Object[] args, String defaultMessage, boolean htmlEscape) {
  String msg = this.webApplicationContext.getMessage(code, args, defaultMessage, getLocale());
  if (msg == null) {
    return "";
  }
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
}

代码示例来源:origin: org.springframework/spring-webmvc

/**
 * 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.webApplicationContext.getMessage(resolvable, getLocale());
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Retrieve the message for the given code, using the "defaultHtmlEscape" setting.
 * @param code code of the message
 * @param args arguments for the message as a List, or {@code null} if none
 * @param defaultMessage String to return if the lookup fails
 * @return the message
 */
public String getMessage(String code, List<?> args, String defaultMessage) {
  return getMessage(code, (args != null ? args.toArray() : null), defaultMessage, isDefaultHtmlEscape());
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Retrieve the message for the given code, using the "defaultHtmlEscape" setting.
 * @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 getMessage(String code, List<?> args) throws NoSuchMessageException {
  return getMessage(code, (args != null ? args.toArray() : null), isDefaultHtmlEscape());
}

代码示例来源:origin: cn.jeeweb/jeeweb-beetl-tag

/**
 * 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 NoSuchMessageException if not found
 */
public String getMessage(String code, @Nullable Object[] args, boolean htmlEscape) throws NoSuchMessageException {
  String msg = this.webApplicationContext.getMessage(code, args, getLocale());
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
}

代码示例来源:origin: apache/servicemix-bundles

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

代码示例来源:origin: org.unbroken-dome.siren/siren-spring

@Override
  public String get() {
    HttpServletRequest request = RequestUtils.getCurrentRequest();
    WebApplicationContext applicationContext = RequestContextUtils.findWebApplicationContext(request);
    return applicationContext.getMessage(resolvableTitle, request.getLocale());
  }
}

代码示例来源:origin: cn.jeeweb/jeeweb-beetl-tag

/**
 * 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 NoSuchMessageException if not found
 */
public String getMessage(MessageSourceResolvable resolvable, boolean htmlEscape) throws NoSuchMessageException {
  String msg = this.webApplicationContext.getMessage(resolvable, getLocale());
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
}

代码示例来源:origin: cn.jeeweb/jeeweb-beetl-tag

/**
 * 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 defaultMessage the String to return if the lookup fails
 * @param htmlEscape if the message should be HTML-escaped
 * @return the message
 */
public String getMessage(String code, @Nullable Object[] args, String defaultMessage, boolean htmlEscape) {
  String msg = this.webApplicationContext.getMessage(code, args, defaultMessage, getLocale());
  if (msg == null) {
    return "";
  }
  return (htmlEscape ? HtmlUtils.htmlEscape(msg) : msg);
}

代码示例来源:origin: com.gitee.qdbp/qdbp-base-ctl

/** {@inheritDoc} **/
@Override
public String getResultCodeMessage(String resultCode) {
  Locale locale = I18nTools.getLocale();
  WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
  String key = generateResultCodeKey(resultCode);
  try {
    String message = context.getMessage(key, null, locale);
    if (key.equals(message)) { // useCodeAsDefaultMessage
      return getDefaultMessage(resultCode, locale);
    } else {
      return message;
    }
  } catch (NoSuchMessageException e) { // 未配置资源文件
    return getDefaultMessage(resultCode, locale);
  }
}

代码示例来源:origin: org.sakaiproject.metaobj/sakai-metaobj-tool-lib

message.addContent(context.getMessage(error, getResourceLoader().getLocale()));
errorElement.addContent(message);
errorsElement.addContent(errorElement);

相关文章