예제 #1
0
파일: AppConfig.java 프로젝트: imxood/app
  @Override
  public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {

    System.out.println("AppConfig.configureMessageConverters()----------------配置转换器");
    final FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
    List<MediaType> supportedMediaTypes = new ArrayList<MediaType>();
    supportedMediaTypes.add(new MediaType("text", "plain"));
    supportedMediaTypes.add(new MediaType("application", "json"));
    converter.setSupportedMediaTypes(supportedMediaTypes);
    converters.add(converter);
    super.configureMessageConverters(converters);
  }
 @Override
 protected void writeInternal(Object obj, HttpOutputMessage outputMessage)
     throws IOException, HttpMessageNotWritableException {
   if (obj != null && obj instanceof Page) {
     Page target = (Page) obj;
     if (target.isConvert()) {
       // 分页适配
       AdapterPage page = getPage(target);
       super.writeInternal(page, outputMessage);
       return;
     }
   }
   super.writeInternal(obj, outputMessage);
 }
 @Bean
 public FastJsonHttpMessageConverter mappingJackson2HttpMessageConverter() {
   FastJsonHttpMessageConverter jsonConverter = new FastJsonHttpMessageConverter();
   jsonConverter.setFeatures(SerializerFeature.PrettyFormat);
   return jsonConverter;
 }