Update reference documentation for JSONP support
Issue: SPR-12113
This commit is contained in:
@@ -1063,7 +1063,8 @@ method has been added.
|
|||||||
summary vs. detail page). This is also supported with View-based rendering by
|
summary vs. detail page). This is also supported with View-based rendering by
|
||||||
adding the serialization view type as a model attribute under a special key.
|
adding the serialization view type as a model attribute under a special key.
|
||||||
See <<mvc-ann-jsonview>> for details.
|
See <<mvc-ann-jsonview>> for details.
|
||||||
* JSONP is now supported with Jackson.
|
* JSONP is now supported with Jackson, both for <<mvc-ann-jsonp,response body methods>> and
|
||||||
|
<<view-json-mapping,`View`-based rendering>>.
|
||||||
* A new lifecycle option is available for intercepting `@ResponseBody` and `ResponseEntity`
|
* A new lifecycle option is available for intercepting `@ResponseBody` and `ResponseEntity`
|
||||||
methods just after the controller method returns and before the response is written.
|
methods just after the controller method returns and before the response is written.
|
||||||
To take advantage declare an `@ControllerAdvice` bean that implements `ResponseBodyAdvice`.
|
To take advantage declare an `@ControllerAdvice` bean that implements `ResponseBodyAdvice`.
|
||||||
@@ -31710,9 +31711,27 @@ to the model:
|
|||||||
return "userView";
|
return "userView";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
[[mvc-ann-jsonp]]
|
||||||
|
===== Jackson JSONP Support
|
||||||
|
|
||||||
|
In order to enable http://en.wikipedia.org/wiki/JSONP[JSONP] support for your response
|
||||||
|
body methods, declare an `@ControllerAdvice` as shown below:
|
||||||
|
|
||||||
|
[source,java,indent=0]
|
||||||
|
[subs="verbatim,quotes"]
|
||||||
|
----
|
||||||
|
@ControllerAdvice
|
||||||
|
public class JsonpAdvice extends AbstractJsonpResponseBodyAdvice {
|
||||||
|
|
||||||
|
public JsonpAdvice() {
|
||||||
|
super("callback");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
----
|
||||||
|
|
||||||
|
|
||||||
[[mvc-ann-async]]
|
[[mvc-ann-async]]
|
||||||
==== Asynchronous Request Processing
|
==== Asynchronous Request Processing
|
||||||
Spring MVC 3.2 introduced Servlet 3 based asynchronous request processing. Instead of
|
Spring MVC 3.2 introduced Servlet 3 based asynchronous request processing. Instead of
|
||||||
@@ -37004,6 +37023,10 @@ annotations. When further control is needed, a custom `ObjectMapper` can be inje
|
|||||||
through the `ObjectMapper` property for cases where custom JSON
|
through the `ObjectMapper` property for cases where custom JSON
|
||||||
serializers/deserializers need to be provided for specific types.
|
serializers/deserializers need to be provided for specific types.
|
||||||
|
|
||||||
|
http://en.wikipedia.org/wiki/JSONP[JSONP] is supported and automatically enabled when
|
||||||
|
the request has a query parameter named `jsonp` or `callback`. The JSONP query parameter
|
||||||
|
name(s) could be customized thanks to the `JsonpParameterNames` property.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user