org.apache.struts2.json
Class JSONActionRedirectResult
java.lang.Object
org.apache.struts2.dispatcher.StrutsResultSupport
org.apache.struts2.dispatcher.ServletRedirectResult
org.apache.struts2.dispatcher.ServletActionRedirectResult
org.apache.struts2.json.JSONActionRedirectResult
- All Implemented Interfaces:
- com.opensymphony.xwork2.Result, com.opensymphony.xwork2.util.reflection.ReflectionExceptionHandler, Serializable, StrutsStatics
public class JSONActionRedirectResult
- extends ServletActionRedirectResult
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:
- Serialized Form
Method Summary |
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)
|
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.util.reflection.ReflectionExceptionHandler |
handle |
JSONActionRedirectResult
public JSONActionRedirectResult()
sendRedirect
protected void sendRedirect(javax.servlet.http.HttpServletResponse response,
String finalLocation)
throws IOException
- Overrides:
sendRedirect
in class ServletRedirectResult
- Throws:
IOException
sendJsonInsteadOfRedirect
protected 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.
printJson
protected void printJson(javax.servlet.http.HttpServletResponse response,
String finalLocation)
throws IOException
- Throws:
IOException
isJsonEnabled
protected boolean isJsonEnabled(javax.servlet.http.HttpServletRequest request)
isValidateOnly
protected boolean isValidateOnly(javax.servlet.http.HttpServletRequest request)
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.