/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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()); }
/** * 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()); }
/** * 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); }
/** * 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); }
@Override public String get() { HttpServletRequest request = RequestUtils.getCurrentRequest(); WebApplicationContext applicationContext = RequestContextUtils.findWebApplicationContext(request); return applicationContext.getMessage(resolvableTitle, request.getLocale()); } }
/** * 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); }
/** * 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); }
/** {@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); } }
message.addContent(context.getMessage(error, getResourceLoader().getLocale())); errorElement.addContent(message); errorsElement.addContent(errorElement);