From 06f1f495c26bf2e6100c29fdf0c3cd6d19fa8240 Mon Sep 17 00:00:00 2001 From: Sebastien Deleuze Date: Wed, 3 Sep 2014 11:14:38 +0200 Subject: [PATCH] Update reference documentation for JSONP support Issue: SPR-12113 --- src/asciidoc/index.adoc | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/asciidoc/index.adoc b/src/asciidoc/index.adoc index 588c94cb074..7299c2ced49 100644 --- a/src/asciidoc/index.adoc +++ b/src/asciidoc/index.adoc @@ -1063,7 +1063,8 @@ method has been added. 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. See <> for details. -* JSONP is now supported with Jackson. +* JSONP is now supported with Jackson, both for <> and + <>. * A new lifecycle option is available for intercepting `@ResponseBody` and `ResponseEntity` methods just after the controller method returns and before the response is written. To take advantage declare an `@ControllerAdvice` bean that implements `ResponseBodyAdvice`. @@ -31710,9 +31711,27 @@ to the model: 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]] ==== Asynchronous Request Processing 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 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. +