Class AbstractJsonpResponseBodyAdvice
- java.lang.Object
- org.springframework.web.servlet.mvc.method.annotation.AbstractMappingJacksonResponseBodyAdvice
- org.springframework.web.servlet.mvc.method.annotation.AbstractJsonpResponseBodyAdvice
- All Implemented Interfaces:
ResponseBodyAdvice<Object>
@Deprecated public abstract class AbstractJsonpResponseBodyAdvice extends AbstractMappingJacksonResponseBodyAdvice
Deprecated.Will be removed as of Spring Framework 5.1, use CORS instead.A convenient base class for aResponseBodyAdviceto instruct theMappingJackson2HttpMessageConverterto serialize with JSONP formatting.Sub-classes must specify the query parameter name(s) to check for the name of the JSONP callback function.
Sub-classes are likely to be annotated with the
@ControllerAdviceannotation and auto-detected or otherwise must be registered directly with theRequestMappingHandlerAdapterandExceptionHandlerExceptionResolver.- Since:
- 4.1
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractJsonpResponseBodyAdvice(String... queryParamNames)Deprecated.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidbeforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response)Deprecated.Invoked only if the converter type isMappingJackson2HttpMessageConverter.protected MediaTypegetContentType(MediaType contentType, ServerHttpRequest request, ServerHttpResponse response)Deprecated.Return the content type to set the response to.protected booleanisValidJsonpQueryParam(String value)Deprecated.Validate the jsonp query parameter value.Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.AbstractMappingJacksonResponseBodyAdvice
beforeBodyWrite, getOrCreateContainer, supports
Constructor Detail
AbstractJsonpResponseBodyAdvice
protected AbstractJsonpResponseBodyAdvice(String... queryParamNames)
Deprecated.
Method Detail
beforeBodyWriteInternal
protected void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response)
Deprecated.Description copied from class:AbstractMappingJacksonResponseBodyAdviceInvoked only if the converter type isMappingJackson2HttpMessageConverter.- Specified by:
beforeBodyWriteInternalin classAbstractMappingJacksonResponseBodyAdvice
isValidJsonpQueryParam
protected boolean isValidJsonpQueryParam(String value)
Deprecated.Validate the jsonp query parameter value. The default implementation returns true if it consists of digits, letters, or "_" and ".". Invalid parameter values are ignored.- Parameters:
value- the query param value, nevernull- Since:
- 4.1.8
getContentType
protected MediaType getContentType(MediaType contentType, ServerHttpRequest request, ServerHttpResponse response)
Deprecated.Return the content type to set the response to. This implementation always returns "application/javascript".- Parameters:
contentType- the content type selected through content negotiationrequest- the current requestresponse- the current response- Returns:
- the content type to set the response to