@@ -2151,8 +2151,13 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
2151
2151
<classname >ViewResolvers</classname >. The first
2152
2152
<classname >View</classname > in the list that has a compatible
2153
2153
<literal >Content-Type</literal > returns the representation to the
2154
- client. The <literal >Accept</literal > header may include wildcards, for
2155
- example text/*, in which case a <classname >View</classname > whose
2154
+ client. If a compatible view cannot be supplied by the
2155
+ <classname >ViewResolver</classname > chain, then the list of views specified
2156
+ through the <literal >DefaultViews</literal > property will be consulted. This
2157
+ latter option is appropriate for singleton <classname >Views</classname > that
2158
+ can render an appropriate representation of the current resource regardless
2159
+ of the logical view name. The <literal >Accept</literal > header may include
2160
+ wildcards, for example text/*, in which case a <classname >View</classname > whose
2156
2161
Context-Type was text/xml is a compatible match.</para >
2157
2162
2158
2163
<para >To support the resolution of a view based on a file extension,
@@ -2170,6 +2175,7 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
2170
2175
< map>
2171
2176
< entry key="atom" value="application/atom+xml"/>
2172
2177
< entry key="html" value="text/html"/>
2178
+ < entry key="json" value="application/json"/>
2173
2179
< /map>
2174
2180
< /property>
2175
2181
< property name="viewResolvers">
@@ -2181,6 +2187,11 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
2181
2187
< /bean>
2182
2188
< /list>
2183
2189
< /property>
2190
+ < property name="defaultViews">
2191
+ < list>
2192
+ < bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
2193
+ < /list>
2194
+ < /property>
2184
2195
< /bean>
2185
2196
2186
2197
@@ -2206,10 +2217,12 @@ public class TimeBasedAccessInterceptor extends HandlerInterceptorAdapter {
2206
2217
matches the <literal >application/atom+xml</literal > media type. This view is provided by
2207
2218
the <classname >BeanNameViewResolver</classname > that maps to the
2208
2219
<classname >SampleContentAtomView</classname > if the view name returned
2209
- is <classname >content</classname >. Alternatively, client requests can be
2210
- made without a file extension but with the <literal >Accept</literal > header set to the
2211
- preferred media-type, and the same resolution of request to views would
2212
- occur.<!-- Can you reword preceding sentence? I don't follow it.--> </para >
2220
+ is <classname >content</classname >. If the request is made with the file extension
2221
+ <literal >.json</literal >, the <classname >MappingJacksonJsonView</classname > instance from
2222
+ the <literal >DefaultViews</literal > list will be selected regardless of the view name.
2223
+ Alternatively, client requests can be made without a file extension but with the
2224
+ <literal >Accept</literal > header set to the preferred media-type, and the same resolution
2225
+ of request to views would occur.<!-- Can you reword preceding sentence? I don't follow it.--> </para >
2213
2226
2214
2227
<note >
2215
2228
<para >If <classname >ContentNegotiatingViewResolver</classname >'s list
0 commit comments