@Order(value=-2147483648)
@ControllerAdvice
public class JSONPResponseBodyAdvice
extends java.lang.Object
implements org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice<java.lang.Object>
Wrap with the return object from method annotated by @ResponseJSONP
in order to be serialized into jsonp format.
url: /path/to/your/api?callback=functionName
In Spring 3.x, use method directly return a JSONPObject instead.
JSONPObject,
ResponseJSONP| Modifier and Type | Field and Description |
|---|---|
org.apache.commons.logging.Log |
logger |
| Constructor and Description |
|---|
JSONPResponseBodyAdvice() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
beforeBodyWrite(java.lang.Object body,
org.springframework.core.MethodParameter returnType,
org.springframework.http.MediaType selectedContentType,
java.lang.Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> selectedConverterType,
org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response) |
void |
beforeBodyWriteInternal(JSONPObject jsonpObject,
org.springframework.http.MediaType contentType,
org.springframework.core.MethodParameter returnType,
org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response) |
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.
|
boolean |
supports(org.springframework.core.MethodParameter returnType,
java.lang.Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType) |
public boolean supports(org.springframework.core.MethodParameter returnType,
java.lang.Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType)
supports in interface org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice<java.lang.Object>public java.lang.Object beforeBodyWrite(java.lang.Object body,
org.springframework.core.MethodParameter returnType,
org.springframework.http.MediaType selectedContentType,
java.lang.Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> selectedConverterType,
org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response)
beforeBodyWrite in interface org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice<java.lang.Object>public void beforeBodyWriteInternal(JSONPObject jsonpObject, org.springframework.http.MediaType contentType, org.springframework.core.MethodParameter returnType, org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response)
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