public class JSONActionRedirectResult extends ServletActionRedirectResult implements Redirectable
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$"}
actionName, DEFAULT_PARAM, method, namespace
actionMapper, anchor, prependServletContext, requestParameters, statusCode, suppressEmptyParameters
DEFAULT_URL_ENCODING, parseLocation
HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION, STRUTS_PORTLET_CONTEXT
Constructor and Description |
---|
JSONActionRedirectResult() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
isJsonEnabled(javax.servlet.http.HttpServletRequest request) |
protected boolean |
isValidateOnly(javax.servlet.http.HttpServletRequest request) |
protected void |
printJson(javax.servlet.http.HttpServletResponse response,
String finalLocation) |
protected boolean |
sendJsonInsteadOfRedirect()
If browser has called action in a JS/AJAX context we cannot send a
redirect as response.
|
protected void |
sendRedirect(javax.servlet.http.HttpServletResponse response,
String finalLocation) |
execute, getProhibitedResultParams, setActionName, setMethod, setNamespace
addParameter, doExecute, handle, isPathUrl, setActionMapper, setAnchor, setPrependServletContext, setStatusCode, setSuppressEmptyParameters, setUrlHelper
conditionalParse, conditionalParseCollection, getLastFinalLocation, getLocation, setEncode, setLocation, setParse
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handle
protected void sendRedirect(javax.servlet.http.HttpServletResponse response, String finalLocation) throws IOException
sendRedirect
in class ServletRedirectResult
IOException
protected boolean sendJsonInsteadOfRedirect()
protected void printJson(javax.servlet.http.HttpServletResponse response, String finalLocation) throws IOException
IOException
protected boolean isJsonEnabled(javax.servlet.http.HttpServletRequest request)
protected boolean isValidateOnly(javax.servlet.http.HttpServletRequest request)
Copyright © 2000–2020 Apache Software Foundation. All rights reserved.