org.apache.struts2.json

## Class JSONValidationInterceptor

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

- All Implemented Interfaces:
    Interceptor, Serializable

      public class JSONValidationInterceptor
      extends MethodFilterInterceptor

  Serializes validation and action errors into JSON. This interceptor does not perform any validation, so it must follow the 'validation' interceptor on the stack.
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_ENCODING`
    `static String` | `NO_ENCODING_SET_PARAM`
    `static String` | `VALIDATE_JSON_PARAM`
    `static String` | `VALIDATE_ONLY_PARAM`

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

      `excludeMethods, includeMethods`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JSONValidationInterceptor()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected String` | `buildResponse(ValidationAware validationAware)`
    `protected String` | `doIntercept(ActionInvocation invocation)`
    `boolean` | `isJsonEnabled(javax.servlet.http.HttpServletRequest request)`
    `boolean` | `isSetEncoding(javax.servlet.http.HttpServletRequest request)`
    `boolean` | `isValidateOnly(javax.servlet.http.HttpServletRequest request)`
    `void` | `setNoEncodingSetParam(String noEncodingSetParam)` Overrides 'struts.JSONValidation.no.encoding' param name
    `void` | `setValidateJsonParam(String validateJsonParam)` Overrides 'struts.enableJSONValidation' param name
    `void` | `setValidateOnlyParam(String validateOnlyParam)` Overrides 'struts.validateOnly' param name
    `void` | `setValidationFailedStatus(int validationFailedStatus)` HTTP status that will be set in the response if validation fails

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

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

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

      `destroy, init`

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

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

- - ### Field Detail

    - #### VALIDATE_ONLY_PARAM

          public static final String VALIDATE_ONLY_PARAM

      See Also:
        Constant Field Values

    - #### VALIDATE_JSON_PARAM

          public static final String VALIDATE_JSON_PARAM

      See Also:
        Constant Field Values

    - #### NO_ENCODING_SET_PARAM

          public static final String NO_ENCODING_SET_PARAM

      See Also:
        Constant Field Values

    - #### DEFAULT_ENCODING

          public static final String DEFAULT_ENCODING

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### JSONValidationInterceptor

          public JSONValidationInterceptor()

  - ### Method Detail

    - #### doIntercept

          protected String doIntercept(ActionInvocation invocation)
                                throws Exception

      Specified by:
        `doIntercept` in class `MethodFilterInterceptor`
      Throws:
        `Exception`

    - #### isJsonEnabled

          public boolean isJsonEnabled(javax.servlet.http.HttpServletRequest request)

    - #### isValidateOnly

          public boolean isValidateOnly(javax.servlet.http.HttpServletRequest request)

    - #### isSetEncoding

          public boolean isSetEncoding(javax.servlet.http.HttpServletRequest request)

    - #### buildResponse

          protected String buildResponse(ValidationAware validationAware)

      Parameters:
        `validationAware` - the validation aware object
      Returns:
        JSON string that contains the errors and field errors

    - #### setValidationFailedStatus

          public void setValidationFailedStatus(int validationFailedStatus)

      HTTP status that will be set in the response if validation fails
      Parameters:
        `validationFailedStatus` - validation failed status

    - #### setValidateOnlyParam

          public void setValidateOnlyParam(String validateOnlyParam)

      Overrides 'struts.validateOnly' param name
      Parameters:
        `validateOnlyParam` - new param name

    - #### setValidateJsonParam

          public void setValidateJsonParam(String validateJsonParam)

      Overrides 'struts.enableJSONValidation' param name
      Parameters:
        `validateJsonParam` - new param name

    - #### setNoEncodingSetParam

          public void setNoEncodingSetParam(String noEncodingSetParam)

      Overrides 'struts.JSONValidation.no.encoding' param name
      Parameters:
        `noEncodingSetParam` - new param name

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