Пример #1
0
 @Bean
 public View mappingJacksonJsonView() {
   MappingJacksonJsonView jsonView = new MappingJacksonJsonView();
   jsonView.setExtractValueFromSingleKeyModel(true);
   jsonView.setPrettyPrint(true);
   return jsonView;
 }
Пример #2
0
 @Bean
 public ContentNegotiatingViewResolver contentNegotiatingViewResolver() {
   ContentNegotiatingViewResolver result = new ContentNegotiatingViewResolver();
   Map<String, String> mediaTypes = new HashMap<String, String>();
   mediaTypes.put("json", MediaType.APPLICATION_JSON_VALUE);
   result.setMediaTypes(mediaTypes);
   MappingJacksonJsonView jacksonView = new MappingJacksonJsonView();
   jacksonView.setExtractValueFromSingleKeyModel(true);
   Set<String> modelKeys = new HashSet<String>();
   modelKeys.add("events");
   modelKeys.add("event");
   jacksonView.setModelKeys(modelKeys);
   result.setDefaultViews(Collections.singletonList((View) jacksonView));
   return result;
 }