public class JSONValidationInterceptor
extends com.opensymphony.xwork2.interceptor.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.
This stack (defined in struts-default.xml) shows how to use this interceptor with the 'validation' interceptor
<interceptor-stack name="jsonValidationWorkflowStack">
<interceptor-ref name="basicStack"/>
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel</param>
</interceptor-ref>
<interceptor-ref name="jsonValidation"/>
<interceptor-ref name="workflow"/>
</interceptor-stack>
If 'validationFailedStatus' is set it will be used as the Response status when validation fails.
If the request has a parameter 'struts.validateOnly' execution will return after validation (action won't be executed).
A request parameter named 'struts.enableJSONValidation' must be set to 'true' to use this interceptor
If the request has a parameter 'struts.JSONValidation.set.encoding' set to true the character encoding will NOT be set on the response - is needed in portlet environment - for more details see issue WW-3237
| Constructor and Description |
|---|
JSONValidationInterceptor() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
buildResponse(com.opensymphony.xwork2.ValidationAware validationAware) |
protected String |
doIntercept(com.opensymphony.xwork2.ActionInvocation invocation) |
void |
setValidationFailedStatus(int validationFailedStatus)
HTTP status that will be set in the response if validation fails
|
public void setValidationFailedStatus(int validationFailedStatus)
validationFailedStatus - protected String doIntercept(com.opensymphony.xwork2.ActionInvocation invocation) throws Exception
doIntercept in class com.opensymphony.xwork2.interceptor.MethodFilterInterceptorExceptionprotected String buildResponse(com.opensymphony.xwork2.ValidationAware validationAware)
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.