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(org.springframework.http.converter.json.MappingJacksonValue bodyContainer,
org.springframework.http.MediaType contentType,
org.springframework.core.MethodParameter returnType,
org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response)
Invoked only if the converter type is
MappingJackson2HttpMessageConverter . |
protected org.springframework.http.MediaType |
getContentType(org.springframework.http.MediaType contentType,
org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.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, supports
protected AbstractJsonpResponseBodyAdvice(java.lang.String... queryParamNames)
protected void beforeBodyWriteInternal(org.springframework.http.converter.json.MappingJacksonValue bodyContainer, org.springframework.http.MediaType contentType, org.springframework.core.MethodParameter returnType, org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response)
AbstractMappingJacksonResponseBodyAdvice
MappingJackson2HttpMessageConverter
.beforeBodyWriteInternal
in class AbstractMappingJacksonResponseBodyAdvice
protected boolean isValidJsonpQueryParam(java.lang.String value)
value
- the query param value, never null
protected org.springframework.http.MediaType getContentType(org.springframework.http.MediaType contentType, org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response)
contentType
- the content type selected through content negotiationrequest
- the current requestresponse
- the current response