Class FastJsonJsonView
java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.view.AbstractView
com.alibaba.fastjson.support.spring.FastJsonJsonView
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.context.ApplicationContextAware
,org.springframework.web.context.ServletContextAware
,org.springframework.web.servlet.View
public class FastJsonJsonView
extends org.springframework.web.servlet.view.AbstractView
Fastjson for Spring MVC View.
- Since:
- 1.2.9
- Author:
- [email protected], VictorZeng
- See Also:
-
AbstractView
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Charset
Deprecated.protected String
Deprecated.static final String
default content typestatic final String
Default content type for JSONP: "application/javascript".protected SerializerFeature[]
Deprecated.protected SerializeFilter[]
Deprecated.Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
Fields inherited from interface org.springframework.web.servlet.View
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
filterModel
(Map<String, Object> model) Filters out undesired attributes from the given model.Deprecated.Deprecated.Deprecated.Deprecated.boolean
Check extractValueFromSingleKeyModel.protected void
prepareResponse
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) protected void
renderMergedOutputModel
(Map<String, Object> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) void
setCharset
(Charset charset) Deprecated.void
setDateFormat
(String dateFormat) Deprecated.void
setDisableCaching
(boolean disableCaching) Disables caching of the generated JSON.void
setExtractValueFromSingleKeyModel
(boolean extractValueFromSingleKeyModel) Set extractValueFromSingleKeyModel.void
setFastJsonConfig
(FastJsonConfig fastJsonConfig) void
setFeatures
(SerializerFeature... features) Deprecated.void
setFilters
(SerializeFilter... filters) Deprecated.void
setJsonpParameterNames
(Set<String> jsonpParameterNames) Set JSONP request parameter names.void
setRenderedAttributes
(Set<String> renderedAttributes) Set renderedAttributes.protected void
setResponseContentType
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) void
setSerializerFeature
(SerializerFeature... features) Deprecated.void
setUpdateContentLength
(boolean updateContentLength) Whether to update the 'Content-Length' header of the response.Methods inherited from class org.springframework.web.servlet.view.AbstractView
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, formatViewName, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, toString, writeToResponse
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
-
Field Details
-
DEFAULT_CONTENT_TYPE
default content type- See Also:
-
DEFAULT_JSONP_CONTENT_TYPE
Default content type for JSONP: "application/javascript".- See Also:
-
charset
Deprecated. -
features
Deprecated. -
filters
Deprecated. -
dateFormat
Deprecated.
-
-
Constructor Details
-
FastJsonJsonView
public FastJsonJsonView()Set default param.
-
-
Method Details
-
getFastJsonConfig
- Returns:
- the fastJsonConfig.
- Since:
- 1.2.11
-
setFastJsonConfig
- Parameters:
fastJsonConfig
- the fastJsonConfig to set.- Since:
- 1.2.11
-
setSerializerFeature
Deprecated.Sets serializer feature.- Parameters:
features
- the features- See Also:
-
getCharset
Deprecated.Gets charset.- Returns:
- the charset
- See Also:
-
setCharset
Deprecated.Sets charset.- Parameters:
charset
- the charset- See Also:
-
getDateFormat
Deprecated.Gets date format.- Returns:
- the date format
- See Also:
-
setDateFormat
Deprecated.Sets date format.- Parameters:
dateFormat
- the date format- See Also:
-
getFeatures
Deprecated.Get features serializer feature [].- Returns:
- the serializer feature []
- See Also:
-
setFeatures
Deprecated.Sets features.- Parameters:
features
- the features- See Also:
-
getFilters
Deprecated.Get filters serialize filter [].- Returns:
- the serialize filter []
- See Also:
-
setFilters
Deprecated.Sets filters.- Parameters:
filters
- the filters- See Also:
-
setRenderedAttributes
Set renderedAttributes.- Parameters:
renderedAttributes
- renderedAttributes
-
isExtractValueFromSingleKeyModel
public boolean isExtractValueFromSingleKeyModel()Check extractValueFromSingleKeyModel.- Returns:
- extractValueFromSingleKeyModel
-
setExtractValueFromSingleKeyModel
public void setExtractValueFromSingleKeyModel(boolean extractValueFromSingleKeyModel) Set extractValueFromSingleKeyModel.- Parameters:
extractValueFromSingleKeyModel
-
-
setJsonpParameterNames
Set JSONP request parameter names. Each time a request has one of those parameters, the resulting JSON will be wrapped into a function named as specified by the JSONP request parameter value.The parameter names configured by default are "jsonp" and "callback".
- Since:
- 4.1
- See Also:
-
renderMergedOutputModel
protected void renderMergedOutputModel(Map<String, Object> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception- Specified by:
renderMergedOutputModel
in classorg.springframework.web.servlet.view.AbstractView
- Throws:
Exception
-
prepareResponse
protected void prepareResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) - Overrides:
prepareResponse
in classorg.springframework.web.servlet.view.AbstractView
-
setDisableCaching
public void setDisableCaching(boolean disableCaching) Disables caching of the generated JSON.Default is
true
, which will prevent the client from caching the generated JSON. -
setUpdateContentLength
public void setUpdateContentLength(boolean updateContentLength) Whether to update the 'Content-Length' header of the response. When set totrue
, the response is buffered in order to determine the content length and set the 'Content-Length' header of the response.The default setting is
false
. -
filterModel
Filters out undesired attributes from the given model. The return value can be either anotherMap
, or a single value object.Default implementation removes
BindingResult
instances and entries not included in therenderedAttributes
property.- Parameters:
model
- the model, as passed on torenderMergedOutputModel(java.util.Map<java.lang.String, java.lang.Object>, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
- Returns:
- the object to be rendered
-
setResponseContentType
protected void setResponseContentType(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) - Overrides:
setResponseContentType
in classorg.springframework.web.servlet.view.AbstractView
-