Package org.springframework.web.util
Class BindErrorUtils
java.lang.Object
org.springframework.web.util.BindErrorUtils
Utility methods to resolve a list of
MessageSourceResolvable
s, and
optionally join them.- Since:
- 6.1
- Author:
- Rossen Stoyanchev
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends MessageSourceResolvable>
Map<E,String> Shortcut forresolve(List, MessageSource, Locale)
with an emptyMessageSource
that 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 String
resolveAndJoin
(CharSequence delimiter, CharSequence prefix, CharSequence suffix, List<? extends MessageSourceResolvable> errors, MessageSource messageSource, Locale locale) Resolve all errors through the givenMessageSource
and join them.static String
resolveAndJoin
(List<? extends MessageSourceResolvable> errors) Shortcut forresolveAndJoin(List, MessageSource, Locale)
with an emptyMessageSource
that simply formats the default message, or first error code, also prepending the field name for field errors.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.
-
Constructor Details
-
BindErrorUtils
public BindErrorUtils()
-
-
Method Details
-
resolveAndJoin
Shortcut forresolveAndJoin(List, MessageSource, Locale)
with an emptyMessageSource
that 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 givenMessageSource
and 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
- theMessageSource
to resolve withlocale
- the locale to resolve with- Returns:
- the resolved errors formatted as a string
-
resolve
Shortcut forresolve(List, MessageSource, Locale)
with an emptyMessageSource
that 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
- theMessageSource
to resolve withlocale
- the locale to resolve with an emptyMessageSource
- Returns:
- map with resolved errors as values, in the order of the input list
-