org.springframework.beans

## 类 TypeMismatchException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.lang.RuntimeException
      - - org.springframework.core.NestedRuntimeException
        - - org.springframework.beans.BeansException
          - - org.springframework.beans.PropertyAccessException
            - - org.springframework.beans.TypeMismatchException

- 所有已实现的接口:
    Serializable
  直接已知子类:
    ConversionNotSupportedException

      public class TypeMismatchException
      extends PropertyAccessException

  Exception thrown on a type mismatch when trying to set a bean property.
  作者:
    Rod Johnson, Juergen Hoeller
  另请参阅:
    序列化表格

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static String` | `ERROR_CODE` Error code that a type mismatch error will be registered with.

  - ### 构造器概要

    构造器
    构造器和说明
    `TypeMismatchException(Object value, Class<?> requiredType)` Create a new `TypeMismatchException` without a `PropertyChangeEvent`.
    `TypeMismatchException(Object value, Class<?> requiredType, Throwable cause)` Create a new `TypeMismatchException` without a `PropertyChangeEvent`.
    `TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType)` Create a new `TypeMismatchException`.
    `TypeMismatchException(PropertyChangeEvent propertyChangeEvent, Class<?> requiredType, Throwable cause)` Create a new `TypeMismatchException`.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `String` | `getErrorCode()` Return a corresponding error code for this type of exception.
    `String` | `getPropertyName()` Return the name of the affected property, if available.
    `Class<?>` | `getRequiredType()` Return the required target type, if any.
    `Object` | `getValue()` Return the offending value (may be `null`).
    `void` | `initPropertyName(String propertyName)` Initialize this exception's property name for exposure through `getPropertyName()`, as an alternative to having it initialized via a `PropertyChangeEvent`.

    - ### 从类继承的方法 org.springframework.beans.PropertyAccessException

      `getPropertyChangeEvent`

    - ### 从类继承的方法 org.springframework.core.NestedRuntimeException

      `contains, getMessage, getMostSpecificCause, getRootCause`

    - ### 从类继承的方法 java.lang.Throwable

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 字段详细资料

    - #### ERROR_CODE

          public static final String ERROR_CODE

      Error code that a type mismatch error will be registered with.
      另请参阅:
        常量字段值

  - ### 构造器详细资料

    - #### TypeMismatchException

          public TypeMismatchException(PropertyChangeEvent propertyChangeEvent,
                                       Class<?> requiredType)

      Create a new `TypeMismatchException`.
      参数:
        `propertyChangeEvent` - the PropertyChangeEvent that resulted in the problem
        `requiredType` - the required target type

    - #### TypeMismatchException

          public TypeMismatchException(PropertyChangeEvent propertyChangeEvent,
                                       @Nullable
                                       Class<?> requiredType,
                                       @Nullable
                                       Throwable cause)

      Create a new `TypeMismatchException`.
      参数:
        `propertyChangeEvent` - the PropertyChangeEvent that resulted in the problem
        `requiredType` - the required target type (or `null` if not known)
        `cause` - the root cause (may be `null`)

    - #### TypeMismatchException

          public TypeMismatchException(@Nullable
                                       Object value,
                                       @Nullable
                                       Class<?> requiredType)

      Create a new `TypeMismatchException` without a `PropertyChangeEvent`.
      参数:
        `value` - the offending value that couldn't be converted (may be `null`)
        `requiredType` - the required target type (or `null` if not known)
      另请参阅:
        `initPropertyName(java.lang.String)`

    - #### TypeMismatchException

          public TypeMismatchException(@Nullable
                                       Object value,
                                       @Nullable
                                       Class<?> requiredType,
                                       @Nullable
                                       Throwable cause)

      Create a new `TypeMismatchException` without a `PropertyChangeEvent`.
      参数:
        `value` - the offending value that couldn't be converted (may be `null`)
        `requiredType` - the required target type (or `null` if not known)
        `cause` - the root cause (may be `null`)
      另请参阅:
        `initPropertyName(java.lang.String)`

  - ### 方法详细资料

    - #### initPropertyName

          public void initPropertyName(String propertyName)

      Initialize this exception's property name for exposure through `getPropertyName()`, as an alternative to having it initialized via a `PropertyChangeEvent`.
      参数:
        `propertyName` - the property name to expose
      从以下版本开始:
        5.0.4
      另请参阅:
        `TypeMismatchException(Object, Class)`, `TypeMismatchException(Object, Class, Throwable)`

    - #### getPropertyName

          @Nullable
          public String getPropertyName()

      Return the name of the affected property, if available.
      覆盖:
        `getPropertyName` 在类中 `PropertyAccessException`

    - #### getValue

          @Nullable
          public Object getValue()

      Return the offending value (may be `null`).
      覆盖:
        `getValue` 在类中 `PropertyAccessException`

    - #### getRequiredType

          @Nullable
          public Class<?> getRequiredType()

      Return the required target type, if any.

    - #### getErrorCode

          public String getErrorCode()

      从类复制的说明: `PropertyAccessException`
      Return a corresponding error code for this type of exception.
      指定者:
        `getErrorCode` 在类中 `PropertyAccessException`