public class JSONInterceptor extends AbstractInterceptor
Constructor and Description |
---|
JSONInterceptor() |
Modifier and Type | Method and Description |
---|---|
protected String |
addCallbackIfApplicable(javax.servlet.http.HttpServletRequest request,
String json) |
String |
getCallbackParameter() |
boolean |
getDebug() |
protected List |
getIncludeProperties() |
String |
intercept(ActionInvocation invocation) |
RPCResponse |
invoke(Object object,
Map data) |
boolean |
isEnableGZIP() |
boolean |
isEnableSMD() |
boolean |
isExcludeNullProperties() |
boolean |
isNoCache() |
protected String |
readContentType(javax.servlet.http.HttpServletRequest request) |
protected String |
readContentTypeEncoding(javax.servlet.http.HttpServletRequest request) |
void |
setCallbackParameter(String callbackParameter) |
void |
setDebug(boolean debug)
Turns debugging on or off
|
void |
setDefaultEncoding(String val) |
void |
setDevMode(String mode) |
void |
setEnableGZIP(boolean enableGZIP)
Setting this property to "true" will compress the output.
|
void |
setEnableSMD(boolean enableSMD) |
void |
setExcludeNullProperties(boolean excludeNullProperties) |
void |
setExcludeProperties(String commaDelim)
Sets a comma-delimited list of regular expressions to match properties
that should be excluded from the JSON output.
|
void |
setExcludeWildcards(String commaDelim)
Sets a comma-delimited list of wildcard expressions to match
properties that should be excluded from the JSON output.
|
void |
setIgnoreHierarchy(boolean ignoreHierarchy) |
void |
setIgnoreSMDMethodInterfaces(boolean ignoreSMDMethodInterfaces)
Ignore annotations on methods in interfaces You may need to set to this
true if your action is a proxy/enhanced as annotations are not inherited
|
void |
setIncludeProperties(String commaDelim)
Sets a comma-delimited list of regular expressions to match properties
that should be included from the JSON output.
|
void |
setIncludeWildcards(String commaDelim)
Sets a comma-delimited list of wildcard expressions to match
properties that should be included from the JSON output.
|
void |
setJSONCleaner(JSONCleaner dataCleaner)
Sets the JSONCleaner to be used
|
void |
setJsonContentType(String jsonContentType) |
void |
setJSONPopulator(JSONPopulator populator)
Sets the JSONPopulator to be used
|
void |
setJsonRpcContentType(String jsonRpcContentType) |
void |
setNoCache(boolean noCache)
Add headers to response to prevent the browser from caching the response
|
void |
setPrefix(boolean prefix) |
void |
setRoot(String root)
Sets the root object to be deserialized, defaults to the Action
|
void |
setWrapWithComments(boolean wrapWithComments)
Wrap generated JSON with comments.
|
destroy, init
public String intercept(ActionInvocation invocation) throws Exception
intercept
in interface Interceptor
intercept
in class AbstractInterceptor
Exception
protected String readContentType(javax.servlet.http.HttpServletRequest request)
protected String readContentTypeEncoding(javax.servlet.http.HttpServletRequest request)
public RPCResponse invoke(Object object, Map data) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, JSONException, InstantiationException, NoSuchMethodException, IntrospectionException
protected String addCallbackIfApplicable(javax.servlet.http.HttpServletRequest request, String json)
public boolean isEnableSMD()
public void setEnableSMD(boolean enableSMD)
public void setIgnoreSMDMethodInterfaces(boolean ignoreSMDMethodInterfaces)
ignoreSMDMethodInterfaces
- set the flag for ignore SMD method interfacespublic void setWrapWithComments(boolean wrapWithComments)
wrapWithComments
- Wrap generated JSON with comments.public void setDefaultEncoding(String val)
public void setIgnoreHierarchy(boolean ignoreHierarchy)
ignoreHierarchy
- Ignore properties defined on base classes of the root object.public void setRoot(String root)
root
- OGNL expression of root object to be serializedpublic void setJSONPopulator(JSONPopulator populator)
populator
- JSONPopulatorpublic void setJSONCleaner(JSONCleaner dataCleaner)
dataCleaner
- JSONCleanerpublic boolean getDebug()
public void setDebug(boolean debug)
debug
- true or falsepublic void setDevMode(String mode)
public void setExcludeProperties(String commaDelim)
commaDelim
- A comma-delimited list of regular expressionspublic void setExcludeWildcards(String commaDelim)
commaDelim
- A comma-delimited list of wildcard expressionspublic void setIncludeProperties(String commaDelim)
commaDelim
- A comma-delimited list of regular expressionspublic void setIncludeWildcards(String commaDelim)
commaDelim
- A comma-delimited list of wildcard expressionsprotected List getIncludeProperties()
public boolean isEnableGZIP()
public void setEnableGZIP(boolean enableGZIP)
enableGZIP
- Enable compressed outputpublic boolean isNoCache()
public void setNoCache(boolean noCache)
noCache
- no cachepublic boolean isExcludeNullProperties()
public void setExcludeNullProperties(boolean excludeNullProperties)
excludeNullProperties
- Do not serialize properties with a null valuepublic void setCallbackParameter(String callbackParameter)
public String getCallbackParameter()
public void setPrefix(boolean prefix)
prefix
- Add "{} && " to generated JSONpublic void setJsonContentType(String jsonContentType)
public void setJsonRpcContentType(String jsonRpcContentType)
Copyright © 2000–2020 Apache Software Foundation. All rights reserved.