コード例 #1
0
ファイル: BaseController.java プロジェクト: gruter/drone
 protected void setJsonResponse(Object bean, HttpServletResponse response)
     throws HttpMessageNotWritableException, IOException {
   MediaType jsonMimeType = MediaType.APPLICATION_JSON;
   if (jsonConverter.canWrite(String.class, jsonMimeType)) {
     jsonConverter.write(bean, jsonMimeType, new ServletServerHttpResponse(response));
   }
 }
コード例 #2
0
  @Bean
  List<HttpMessageConverter<?>> httpMessageConverters() {
    Assert.notNull(httpMessageConverters);

    if (httpMessageConverters.isEmpty()) {
      MappingJacksonHttpMessageConverter json = new MappingJacksonHttpMessageConverter();
      json.setSupportedMediaTypes(
          Arrays.asList(
              MediaType.APPLICATION_JSON, MediaType.valueOf("application/x-spring-data+json")));
      httpMessageConverters.add(json);
    }

    return httpMessageConverters;
  }
コード例 #3
0
 @Override
 protected MappingJacksonHttpMessageConverter getJsonMessageConverter() {
   MappingJacksonHttpMessageConverter converter = super.getJsonMessageConverter();
   FlickrObjectMapper objectMapper = new FlickrObjectMapper();
   objectMapper.registerModule(new FlickrModule());
   objectMapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
   objectMapper.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE);
   List<MediaType> supportedMediaTypes = new ArrayList<MediaType>();
   supportedMediaTypes.add(MediaType.TEXT_PLAIN);
   supportedMediaTypes.add(MediaType.TEXT_XML);
   supportedMediaTypes.add(MediaType.APPLICATION_JSON);
   converter.setSupportedMediaTypes(supportedMediaTypes);
   converter.setObjectMapper(objectMapper);
   return converter;
 }