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 TypeMethodDescriptionstatic <E extends MessageSourceResolvable>
Map<E, String> 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.static <E extends MessageSourceResolvable>
Map<E, String> resolve(List<E> errors, MessageSource messageSource, Locale locale) Resolve all errors through the givenMessageSource.static StringresolveAndJoin(CharSequence delimiter, CharSequence prefix, CharSequence suffix, List<? extends MessageSourceResolvable> errors, MessageSource messageSource, Locale locale) Resolve all errors through the givenMessageSourceand join them.static StringresolveAndJoin(List<? extends 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 MessageSourceResolvable> errors, 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
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 MessageSourceResolvable> errors, 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 MessageSourceResolvable> errors, 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
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 MessageSourceResolvable> Map<E,String> resolve(List<E> errors, 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
-