接口 BindingErrorProcessor
- 所有已知实现类:
DefaultBindingErrorProcessor
public interface BindingErrorProcessor
Strategy for processingDataBinder's missing field errors, and for translating aPropertyAccessExceptionto aFieldError.The error processor is pluggable so you can treat errors differently if you want to. A default implementation is provided for typical needs.
Note: As of Spring 2.0, this interface operates on a given BindingResult, to be compatible with any binding strategy (bean property, direct field access, etc). It can still receive a BindException as argument (since a BindException implements the BindingResult interface as well) but no longer operates on it directly.
- 从以下版本开始:
- 1.2
- 作者:
- Alef Arendsen, Juergen Hoeller
- 另请参阅:
DataBinder.setBindingErrorProcessor(org.springframework.validation.BindingErrorProcessor),DefaultBindingErrorProcessor,BindingResult,BindException
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 voidprocessMissingFieldError(String missingField, BindingResult bindingResult)Apply the missing field error to the given BindException.voidprocessPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult)Translate the givenPropertyAccessExceptionto an appropriate error registered on the givenErrorsinstance.
方法详细资料
processMissingFieldError
void processMissingFieldError(String missingField, BindingResult bindingResult)
Apply the missing field error to the given BindException.Usually, a field error is created for a missing required field.
- 参数:
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. TheBindingResultobject features convenience utils such as aresolveMessageCodesmethod to resolve an error code.- 另请参阅:
AbstractBindingResult.addError(org.springframework.validation.ObjectError),AbstractBindingResult.resolveMessageCodes(java.lang.String)
processPropertyAccessException
void processPropertyAccessException(PropertyAccessException ex, BindingResult bindingResult)
Translate the givenPropertyAccessExceptionto an appropriate error registered on the givenErrorsinstance.Note that two error types are available:
FieldErrorandObjectError. Usually, field errors are created, but in certain situations one might want to create a globalObjectErrorinstead.- 参数:
ex- thePropertyAccessExceptionto translatebindingResult- the errors object to add the error(s) to. You can add more than just one error or maybe even ignore it. TheBindingResultobject features convenience utils such as aresolveMessageCodesmethod to resolve an error code.- 另请参阅:
Errors,FieldError,ObjectError,MessageCodesResolver,AbstractBindingResult.addError(org.springframework.validation.ObjectError),AbstractBindingResult.resolveMessageCodes(java.lang.String)