Package org.springframework.web.util
Class BindErrorUtils
java.lang.Object
org.springframework.web.util.BindErrorUtils
Utility methods to resolve a list of
MessageSourceResolvables, and
optionally join them.- Since:
- 6.1
- Author:
- Rossen Stoyanchev
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionShortcut forresolve(List, MessageSource, Locale)with an emptyMessageSourcethat simply formats the default message, or first error code, also prepending the field name for field errors.Resolve all errors through the givenMessageSource.static StringresolveAndJoin(CharSequence delimiter, CharSequence prefix, CharSequence suffix, List<? extends org.springframework.context.MessageSourceResolvable> errors, org.springframework.context.MessageSource messageSource, Locale locale) Resolve all errors through the givenMessageSourceand join them.static StringresolveAndJoin(List<? extends org.springframework.context.MessageSourceResolvable> errors) Shortcut forresolveAndJoin(List, MessageSource, Locale)with an emptyMessageSourcethat simply formats the default message, or first error code, also prepending the field name for field errors.static StringresolveAndJoin(List<? extends org.springframework.context.MessageSourceResolvable> errors, org.springframework.context.MessageSource messageSource, Locale locale) Shortcut forresolveAndJoin(CharSequence, CharSequence, CharSequence, List, MessageSource, Locale)with", and "as delimiter, and an empty prefix and suffix.
-
Constructor Details
-
BindErrorUtils
public BindErrorUtils()
-
-
Method Details
-
resolveAndJoin
public static String resolveAndJoin(List<? extends org.springframework.context.MessageSourceResolvable> errors) Shortcut forresolveAndJoin(List, MessageSource, Locale)with an emptyMessageSourcethat simply formats the default message, or first error code, also prepending the field name for field errors. -
resolveAndJoin
public static String resolveAndJoin(List<? extends org.springframework.context.MessageSourceResolvable> errors, org.springframework.context.MessageSource messageSource, Locale locale) Shortcut forresolveAndJoin(CharSequence, CharSequence, CharSequence, List, MessageSource, Locale)with", and "as delimiter, and an empty prefix and suffix. -
resolveAndJoin
public static String resolveAndJoin(CharSequence delimiter, CharSequence prefix, CharSequence suffix, List<? extends org.springframework.context.MessageSourceResolvable> errors, org.springframework.context.MessageSource messageSource, Locale locale) Resolve all errors through the givenMessageSourceand join them.- Parameters:
delimiter- the delimiter to use between each errorprefix- characters to insert at the beginningsuffix- characters to insert at the enderrors- the errors to resolve and joinmessageSource- theMessageSourceto resolve withlocale- the locale to resolve with- Returns:
- the resolved errors formatted as a string
-
resolve
public static <E extends org.springframework.context.MessageSourceResolvable> Map<E,String> resolve(List<E> errors) Shortcut forresolve(List, MessageSource, Locale)with an emptyMessageSourcethat simply formats the default message, or first error code, also prepending the field name for field errors. -
resolve
public static <E extends org.springframework.context.MessageSourceResolvable> Map<E,String> resolve(List<E> errors, org.springframework.context.MessageSource messageSource, Locale locale) Resolve all errors through the givenMessageSource.- Parameters:
errors- the errors to resolvemessageSource- theMessageSourceto resolve withlocale- the locale to resolve with an emptyMessageSource- Returns:
- map with resolved errors as values, in the order of the input list
-