Skip to content

Commit 06f1f49

Browse files
committed
Update reference documentation for JSONP support
Issue: SPR-12113
1 parent 7885a59 commit 06f1f49

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/asciidoc/index.adoc

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,8 @@ method has been added.
10631063
summary vs. detail page). This is also supported with View-based rendering by
10641064
adding the serialization view type as a model attribute under a special key.
10651065
See <<mvc-ann-jsonview>> for details.
1066-
* JSONP is now supported with Jackson.
1066+
* JSONP is now supported with Jackson, both for <<mvc-ann-jsonp,response body methods>> and
1067+
<<view-json-mapping,`View`-based rendering>>.
10671068
* A new lifecycle option is available for intercepting `@ResponseBody` and `ResponseEntity`
10681069
methods just after the controller method returns and before the response is written.
10691070
To take advantage declare an `@ControllerAdvice` bean that implements `ResponseBodyAdvice`.
@@ -31710,8 +31711,26 @@ to the model:
3171031711
return "userView";
3171131712
}
3171231713
}
31714+
----
31715+
31716+
[[mvc-ann-jsonp]]
31717+
===== Jackson JSONP Support
31718+
31719+
In order to enable http://en.wikipedia.org/wiki/JSONP[JSONP] support for your response
31720+
body methods, declare an `@ControllerAdvice` as shown below:
3171331721

31722+
[source,java,indent=0]
31723+
[subs="verbatim,quotes"]
3171431724
----
31725+
@ControllerAdvice
31726+
public class JsonpAdvice extends AbstractJsonpResponseBodyAdvice {
31727+
31728+
public JsonpAdvice() {
31729+
super("callback");
31730+
}
31731+
}
31732+
----
31733+
3171531734

3171631735
[[mvc-ann-async]]
3171731736
==== Asynchronous Request Processing
@@ -37004,6 +37023,10 @@ annotations. When further control is needed, a custom `ObjectMapper` can be inje
3700437023
through the `ObjectMapper` property for cases where custom JSON
3700537024
serializers/deserializers need to be provided for specific types.
3700637025

37026+
http://en.wikipedia.org/wiki/JSONP[JSONP] is supported and automatically enabled when
37027+
the request has a query parameter named `jsonp` or `callback`. The JSONP query parameter
37028+
name(s) could be customized thanks to the `JsonpParameterNames` property.
37029+
3700737030

3700837031

3700937032

0 commit comments

Comments
 (0)