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 aResponseBodyAdvice
to instruct theMappingJackson2HttpMessageConverter
to 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
@ControllerAdvice
annotation and auto-detected or otherwise must be registered directly with theRequestMappingHandlerAdapter
andExceptionHandlerExceptionResolver
.- Since:
- 4.1
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractJsonpResponseBodyAdvice(String... queryParamNames)
Deprecated.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response)
Deprecated.Invoked only if the converter type isMappingJackson2HttpMessageConverter
.protected MediaType
getContentType(MediaType contentType, ServerHttpRequest request, ServerHttpResponse response)
Deprecated.Return the content type to set the response to.protected boolean
isValidJsonpQueryParam(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:AbstractMappingJacksonResponseBodyAdvice
Invoked only if the converter type isMappingJackson2HttpMessageConverter
.- Specified by:
beforeBodyWriteInternal
in 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