Package org.apache.struts2.json
Class JSONActionRedirectResult
java.lang.Object
org.apache.struts2.result.StrutsResultSupport
org.apache.struts2.result.ServletRedirectResult
org.apache.struts2.result.ServletActionRedirectResult
org.apache.struts2.json.JSONActionRedirectResult
- All Implemented Interfaces:
- Serializable,- Redirectable,- Result,- StrutsStatics,- ReflectionExceptionHandler
Specialized form of 
ServletActionRedirectResult which takes care of
 situation that browser has a JS/AJAX context, there are no validation errors
 and action is executed. In this case a http redirect is harmful as browsers
 don't pass them to JS handlers. So this result produces a JSON response
 containing redirect data.
 To be used along with JSONValidationInterceptor.
Response JSON looks like this:
{"location": "$redirect url$"}
 - See Also:
- 
Field SummaryFields inherited from class org.apache.struts2.result.ServletActionRedirectResultactionName, DEFAULT_PARAM, method, namespaceFields inherited from class org.apache.struts2.result.ServletRedirectResultactionMapper, anchor, prependServletContext, requestParameters, statusCode, suppressEmptyParametersFields inherited from class org.apache.struts2.result.StrutsResultSupportDEFAULT_URL_ENCODING, parseLocationFields inherited from interface org.apache.struts2.StrutsStaticsACTION_MAPPING, HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected booleanisJsonEnabled(jakarta.servlet.http.HttpServletRequest request) protected booleanisValidateOnly(jakarta.servlet.http.HttpServletRequest request) protected voidprotected booleanIf browser has called action in a JS/AJAX context we cannot send a redirect as response.protected voidsendRedirect(jakarta.servlet.http.HttpServletResponse response, String finalLocation) Methods inherited from class org.apache.struts2.result.ServletActionRedirectResultexecute, getProhibitedResultParams, setActionName, setMethod, setNamespaceMethods inherited from class org.apache.struts2.result.ServletRedirectResultaddParameter, doExecute, handle, isPathUrl, setActionMapper, setAnchor, setPrependServletContext, setQueryStringBuilder, setStatusCode, setSuppressEmptyParametersMethods inherited from class org.apache.struts2.result.StrutsResultSupportconditionalParse, conditionalParseCollection, getLastFinalLocation, getLocation, setEncode, setLocation, setParseMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.struts2.util.reflection.ReflectionExceptionHandlerhandle
- 
Constructor Details- 
JSONActionRedirectResultpublic JSONActionRedirectResult()
 
- 
- 
Method Details- 
sendRedirectprotected void sendRedirect(jakarta.servlet.http.HttpServletResponse response, String finalLocation) throws IOException - Overrides:
- sendRedirectin class- ServletRedirectResult
- Throws:
- IOException
 
- 
sendJsonInsteadOfRedirectprotected boolean sendJsonInsteadOfRedirect()If browser has called action in a JS/AJAX context we cannot send a redirect as response.- Returns:
- true if a JSON response shall be generated, false if a redirect shall be sent.
 
- 
printJsonprotected void printJson(jakarta.servlet.http.HttpServletResponse response, String finalLocation) throws IOException - Throws:
- IOException
 
- 
isJsonEnabledprotected boolean isJsonEnabled(jakarta.servlet.http.HttpServletRequest request) 
- 
isValidateOnlyprotected boolean isValidateOnly(jakarta.servlet.http.HttpServletRequest request) 
 
-