类 DefaultBindingErrorProcessor
- java.lang.Object
- org.springframework.validation.DefaultBindingErrorProcessor
- 所有已实现的接口:
BindingErrorProcessor
public class DefaultBindingErrorProcessor extends Object implements BindingErrorProcessor
DefaultBindingErrorProcessor
implementation.Uses the "required" error code and the field name to resolve message codes for a missing field error.
Creates a
FieldError
for eachPropertyAccessException
given, using thePropertyAccessException
's error code ("typeMismatch", "methodInvocation") for resolving message codes.- 从以下版本开始:
- 1.2
- 作者:
- Alef Arendsen, Juergen Hoeller
- 另请参阅:
MISSING_FIELD_ERROR_CODE
,DataBinder.setBindingErrorProcessor(org.springframework.validation.BindingErrorProcessor)
,AbstractBindingResult.addError(org.springframework.validation.ObjectError)
,AbstractBindingResult.resolveMessageCodes(java.lang.String)
,PropertyAccessException.getErrorCode()
,TypeMismatchException.ERROR_CODE
,MethodInvocationException.ERROR_CODE
字段概要
字段 修饰符和类型 字段 说明 static String
MISSING_FIELD_ERROR_CODE
Error code that a missing field error (i.e. a required field not found in the list of property values) will be registered with: "required".
构造器概要
构造器 构造器 说明 DefaultBindingErrorProcessor()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected Object[]
getArgumentsForBindError(String objectName, String field)
Return FieldError arguments for a binding error on the given field.void
processMissingFieldError(String missingField, BindingResult bindingResult)
Apply the missing field error to the given BindException.void
processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult)
Translate the givenPropertyAccessException
to an appropriate error registered on the givenErrors
instance.
字段详细资料
MISSING_FIELD_ERROR_CODE
public static final String MISSING_FIELD_ERROR_CODE
Error code that a missing field error (i.e. a required field not found in the list of property values) will be registered with: "required".- 另请参阅:
- 常量字段值
构造器详细资料
DefaultBindingErrorProcessor
public DefaultBindingErrorProcessor()
方法详细资料
processMissingFieldError
public void processMissingFieldError(String missingField, BindingResult bindingResult)
从接口复制的说明:BindingErrorProcessor
Apply the missing field error to the given BindException.Usually, a field error is created for a missing required field.
- 指定者:
processMissingFieldError
在接口中BindingErrorProcessor
- 参数:
missingField
- the field that was missing during bindingbindingResult
- the errors object to add the error(s) to. You can add more than just one error or maybe even ignore it. TheBindingResult
object features convenience utils such as aresolveMessageCodes
method to resolve an error code.- 另请参阅:
AbstractBindingResult.addError(org.springframework.validation.ObjectError)
,AbstractBindingResult.resolveMessageCodes(java.lang.String)
processPropertyAccessException
public void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult)
从接口复制的说明:BindingErrorProcessor
Translate the givenPropertyAccessException
to an appropriate error registered on the givenErrors
instance.Note that two error types are available:
FieldError
andObjectError
. Usually, field errors are created, but in certain situations one might want to create a globalObjectError
instead.- 指定者:
processPropertyAccessException
在接口中BindingErrorProcessor
- 参数:
ex
- thePropertyAccessException
to translatebindingResult
- the errors object to add the error(s) to. You can add more than just one error or maybe even ignore it. TheBindingResult
object features convenience utils such as aresolveMessageCodes
method to resolve an error code.- 另请参阅:
Errors
,FieldError
,ObjectError
,MessageCodesResolver
,AbstractBindingResult.addError(org.springframework.validation.ObjectError)
,AbstractBindingResult.resolveMessageCodes(java.lang.String)
getArgumentsForBindError
protected Object[] getArgumentsForBindError(String objectName, String field)
Return FieldError arguments for a binding error on the given field. Invoked for each missing required field and each type mismatch.The default implementation returns a single argument indicating the field name (of type DefaultMessageSourceResolvable, with "objectName.field" and "field" as codes).
- 参数:
objectName
- the name of the target objectfield
- the field that caused the binding error- 返回:
- the Object array that represents the FieldError arguments
- 另请参阅:
DefaultMessageSourceResolvable.getArguments()
,DefaultMessageSourceResolvable