public abstract class AbstractJsonpResponseBodyAdvice extends AbstractMappingJacksonResponseBodyAdvice
ResponseBodyAdvice to instruct the
MappingJackson2HttpMessageConverter
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 the
RequestMappingHandlerAdapter and ExceptionHandlerExceptionResolver.
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractJsonpResponseBodyAdvice(java.lang.String... queryParamNames) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
beforeBodyWriteInternal(MappingJacksonValue bodyContainer,
MediaType contentType,
MethodParameter returnType,
ServerHttpRequest request,
ServerHttpResponse response)
Invoked only if the converter type is
MappingJackson2HttpMessageConverter. |
protected MediaType |
getContentType(MediaType contentType,
ServerHttpRequest request,
ServerHttpResponse response)
Return the content type to set the response to.
|
protected boolean |
isValidJsonpQueryParam(java.lang.String value)
Validate the jsonp query parameter value.
|
beforeBodyWrite, getOrCreateContainer, supportsprotected AbstractJsonpResponseBodyAdvice(java.lang.String... queryParamNames)
protected void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response)
AbstractMappingJacksonResponseBodyAdviceMappingJackson2HttpMessageConverter.beforeBodyWriteInternal in class AbstractMappingJacksonResponseBodyAdviceprotected boolean isValidJsonpQueryParam(java.lang.String value)
value - the query param value, never nullprotected MediaType getContentType(MediaType contentType, ServerHttpRequest request, ServerHttpResponse response)
contentType - the content type selected through content negotiationrequest - the current requestresponse - the current response