接口 BindingResult

    • 字段详细资料

      • MODEL_KEY_PREFIX

        static final String MODEL_KEY_PREFIX
        Prefix for the name of the BindingResult instance in a model, followed by the object name.
    • 方法详细资料

      • getTarget

        Object getTarget()
        Return the wrapped target object, which may be a bean, an object with public fields, a Map - depending on the concrete binding strategy.
      • getModel

        Map<String,​ObjectgetModel()
        Return a model Map for the obtained state, exposing a BindingResult instance as 'MODEL_KEY_PREFIX + objectName' and the object itself as 'objectName'.

        Note that the Map is constructed every time you're calling this method. Adding things to the map and then re-calling this method will not work.

        The attributes in the model Map returned by this method are usually included in the ModelAndView for a form view that uses Spring's bind tag in a JSP, which needs access to the BindingResult instance. Spring's pre-built form controllers will do this for you when rendering a form view. When building the ModelAndView instance yourself, you need to include the attributes from the model Map returned by this method.

        另请参阅:
        Errors.getObjectName(), MODEL_KEY_PREFIX, ModelAndView, BindTag
      • getRawFieldValue

        Object getRawFieldValue​(String field)
        Extract the raw field value for the given field. Typically used for comparison purposes.
        参数:
        field - the field to check
        返回:
        the current value of the field in its raw form, or null if not known
      • findEditor

        PropertyEditor findEditor​(String field,
                                  Class<?> valueType)
        Find a custom property editor for the given type and property.
        参数:
        field - the path of the property (name or nested path), or null if looking for an editor for all properties of the given type
        valueType - the type of the property (can be null if a property is given but should be specified in any case for consistency checking)
        返回:
        the registered editor, or null if none
      • resolveMessageCodes

        String[] resolveMessageCodes​(String errorCode)
        Resolve the given error code into message codes.

        Calls the configured MessageCodesResolver with appropriate parameters.

        参数:
        errorCode - the error code to resolve into message codes
        返回:
        the resolved message codes
      • resolveMessageCodes

        String[] resolveMessageCodes​(String errorCode,
                                     String field)
        Resolve the given error code into message codes for the given field.

        Calls the configured MessageCodesResolver with appropriate parameters.

        参数:
        errorCode - the error code to resolve into message codes
        field - the field to resolve message codes for
        返回:
        the resolved message codes