|
44 | 44 | import org.springframework.http.converter.StringHttpMessageConverter;
|
45 | 45 | import org.springframework.http.converter.feed.AtomFeedHttpMessageConverter;
|
46 | 46 | import org.springframework.http.converter.feed.RssChannelHttpMessageConverter;
|
| 47 | +import org.springframework.http.converter.json.GsonHttpMessageConverter; |
47 | 48 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
48 | 49 | import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter;
|
49 | 50 | import org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter;
|
@@ -159,6 +160,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
159 | 160 | ClassUtils.isPresent("com.fasterxml.jackson.databind.ObjectMapper", WebMvcConfigurationSupport.class.getClassLoader()) &&
|
160 | 161 | ClassUtils.isPresent("com.fasterxml.jackson.core.JsonGenerator", WebMvcConfigurationSupport.class.getClassLoader());
|
161 | 162 |
|
| 163 | + private static final boolean gsonPresent = |
| 164 | + ClassUtils.isPresent("com.google.gson.Gson", WebMvcConfigurationSupport.class.getClassLoader()); |
| 165 | + |
162 | 166 |
|
163 | 167 | private ServletContext servletContext;
|
164 | 168 |
|
@@ -290,7 +294,7 @@ protected Map<String, MediaType> getDefaultMediaTypes() {
|
290 | 294 | if (jaxb2Present) {
|
291 | 295 | map.put("xml", MediaType.APPLICATION_XML);
|
292 | 296 | }
|
293 |
| - if (jackson2Present) { |
| 297 | + if (jackson2Present || gsonPresent) { |
294 | 298 | map.put("json", MediaType.APPLICATION_JSON);
|
295 | 299 | }
|
296 | 300 | return map;
|
@@ -605,6 +609,9 @@ protected final void addDefaultHttpMessageConverters(List<HttpMessageConverter<?
|
605 | 609 | if (jackson2Present) {
|
606 | 610 | messageConverters.add(new MappingJackson2HttpMessageConverter());
|
607 | 611 | }
|
| 612 | + else if (gsonPresent) { |
| 613 | + messageConverters.add(new GsonHttpMessageConverter()); |
| 614 | + } |
608 | 615 | }
|
609 | 616 |
|
610 | 617 | /**
|
|
0 commit comments