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 and Type | Field and Description |
---|---|
private java.lang.String[] |
jsonpQueryParamNames |
Modifier | Constructor and Description |
---|---|
protected |
AbstractJsonpResponseBodyAdvice(java.util.Collection<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.
|
beforeBodyWrite, getOrCreateContainer, supports
protected AbstractJsonpResponseBodyAdvice(java.util.Collection<java.lang.String> queryParamNames)
protected void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response)
AbstractMappingJacksonResponseBodyAdvice
MappingJackson2HttpMessageConverter
.beforeBodyWriteInternal
in class AbstractMappingJacksonResponseBodyAdvice
protected MediaType getContentType(MediaType contentType, ServerHttpRequest request, ServerHttpResponse response)
contentType
- the content type selected through content negotiationrequest
- the current requestresponse
- the current response