com.opensymphony.xwork2.interceptor

## Class ConversionErrorInterceptor

- java.lang.Object
- - org.apache.struts2.interceptor.AbstractInterceptor
  - - com.opensymphony.xwork2.interceptor.AbstractInterceptor
    - - com.opensymphony.xwork2.interceptor.MethodFilterInterceptor
      - - com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor

- All Implemented Interfaces:
    Serializable, ConditionalInterceptor, Interceptor
  Direct Known Subclasses:
    StrutsConversionErrorInterceptor

  Deprecated.
  since 6.7.0, use `ConversionErrorInterceptor` instead.

      @Deprecated
      public class ConversionErrorInterceptor
      extends MethodFilterInterceptor

  ConversionErrorInterceptor adds conversion errors from the ActionContext to the Action's field errors.

  This interceptor adds any error found in the `ActionContext`'s conversionErrors map as a field error (provided that the action implements `ValidationAware`). In addition, any field that contains a validation error has its original value saved such that any subsequent requests for that value return the original value rather than the value in the action. This is important because if the value "abc" is submitted and can't be converted to an int, we want to display the original string ("abc") again rather than the int value (likely 0, which would make very little sense to the user).

  Note: Since 2.5.2, this interceptor extends `MethodFilterInterceptor`, therefore being able to deal with excludeMethods / includeMethods parameters. See [Workflow Interceptor] (class `DefaultWorkflowInterceptor`) for documentation and examples on how to use this feature.

  Interceptor parameters:

  - None

  Extending the interceptor:

  Because this interceptor is not web-specific, it abstracts the logic for whether an error should be added. This allows for web-specific interceptors to use more complex logic in the `shouldAddError(java.lang.String, java.lang.Object)` method for when a value has a conversion error but is null or empty or otherwise indicates that the value was never actually entered by the user.

  Example code:

       <action name="someAction" class="com.examples.SomeAction">
           <interceptor-ref name="params"/>
           <interceptor-ref name="conversionError"/>
           <result name="success">good_result.ftl</result>
       </action>

  Author:
    Jason Carreira
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.opensymphony.xwork2.interceptor.ConditionalInterceptor

      `ConditionalInterceptor.LegacyAdapter`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `ORIGINAL_PROPERTY_OVERRIDE` Deprecated.

    - ### Fields inherited from class com.opensymphony.xwork2.interceptor.MethodFilterInterceptor

      `excludeMethods, includeMethods`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConversionErrorInterceptor()` Deprecated.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `doIntercept(ActionInvocation invocation)` Deprecated. Subclasses must override to implement the interceptor logic.
    `protected String` | `escape(Object value)` Deprecated.
    `protected Object` | `getOverrideExpr(ActionInvocation invocation, Object value)` Deprecated.
    `protected boolean` | `shouldAddError(String propertyName, Object value)` Deprecated.

    - ### Methods inherited from class com.opensymphony.xwork2.interceptor.MethodFilterInterceptor

      `applyInterceptor, applyInterceptor, doIntercept, getExcludeMethodsSet, getIncludeMethodsSet, intercept, setExcludeMethods, setIncludeMethods`

    - ### Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor

      `intercept, shouldIntercept, shouldIntercept`

    - ### Methods inherited from class org.apache.struts2.interceptor.AbstractInterceptor

      `destroy, init, setDisabled`

    - ### Methods inherited from class java.lang.Object

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

    - ### Methods inherited from interface com.opensymphony.xwork2.interceptor.ConditionalInterceptor

      `adapt`

    - ### Methods inherited from interface com.opensymphony.xwork2.interceptor.Interceptor

      `adapt`

    - ### Methods inherited from interface org.apache.struts2.interceptor.Interceptor

      `destroy, init`

- - ### Field Detail

    - #### ORIGINAL_PROPERTY_OVERRIDE

          public static final String ORIGINAL_PROPERTY_OVERRIDE

      Deprecated.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ConversionErrorInterceptor

          public ConversionErrorInterceptor()

      Deprecated.

  - ### Method Detail

    - #### getOverrideExpr

          protected Object getOverrideExpr(ActionInvocation invocation,
                                           Object value)

      Deprecated.

    - #### escape

          protected String escape(Object value)

      Deprecated.

    - #### doIntercept

          public String doIntercept(ActionInvocation invocation)
                             throws Exception

      Deprecated.
      Description copied from class: `MethodFilterInterceptor`
      Subclasses must override to implement the interceptor logic.
      Specified by:
        `doIntercept` in class `MethodFilterInterceptor`
      Parameters:
        `invocation` - the action invocation
      Returns:
        the result of invocation
      Throws:
        `Exception` - in case of any errors

    - #### shouldAddError

          protected boolean shouldAddError(String propertyName,
                                           Object value)

      Deprecated.

Copyright © 2000–2026 Apache Software Foundation. All rights reserved.