Class BindErrorUtils

java.lang.Object
org.springframework.web.util.BindErrorUtils

public abstract class BindErrorUtils extends Object
Utility methods to resolve a list of MessageSourceResolvables, and optionally join them.
Since:
6.1
Author:
Rossen Stoyanchev
  • Constructor Details

    • BindErrorUtils

      public BindErrorUtils()
  • Method Details

    • resolveAndJoin

      public static String resolveAndJoin(List<? extends org.springframework.context.MessageSourceResolvable> errors)
      Shortcut for resolveAndJoin(List, MessageSource, Locale) with an empty MessageSource 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 org.springframework.context.MessageSourceResolvable> errors, org.springframework.context.MessageSource messageSource, Locale locale)
      Shortcut for resolveAndJoin(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 given MessageSource and join them.
      Parameters:
      delimiter - the delimiter to use between each error
      prefix - characters to insert at the beginning
      suffix - characters to insert at the end
      errors - the errors to resolve and join
      messageSource - the MessageSource to resolve with
      locale - 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 for resolve(List, MessageSource, Locale) with an empty MessageSource that 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 given MessageSource.
      Parameters:
      errors - the errors to resolve
      messageSource - the MessageSource to resolve with
      locale - the locale to resolve with an empty MessageSource
      Returns:
      map with resolved errors as values, in the order of the input list