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
public static <E extends 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 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
-