| 1 | |
package com.ctrip.framework.apollo.common.controller; |
| 2 | |
|
| 3 | |
import com.google.common.collect.Lists; |
| 4 | |
import com.google.gson.GsonBuilder; |
| 5 | |
|
| 6 | |
import org.springframework.boot.autoconfigure.web.HttpMessageConverters; |
| 7 | |
import org.springframework.context.annotation.Bean; |
| 8 | |
import org.springframework.context.annotation.Configuration; |
| 9 | |
import org.springframework.http.converter.ByteArrayHttpMessageConverter; |
| 10 | |
import org.springframework.http.converter.HttpMessageConverter; |
| 11 | |
import org.springframework.http.converter.StringHttpMessageConverter; |
| 12 | |
import org.springframework.http.converter.json.GsonHttpMessageConverter; |
| 13 | |
import org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter; |
| 14 | |
|
| 15 | |
import java.util.List; |
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
@Configuration |
| 21 | 0 | public class HttpMessageConverterConfiguration { |
| 22 | |
@Bean |
| 23 | |
public HttpMessageConverters messageConverters() { |
| 24 | 0 | GsonHttpMessageConverter gsonHttpMessageConverter = new GsonHttpMessageConverter(); |
| 25 | 0 | gsonHttpMessageConverter.setGson( |
| 26 | 0 | new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").create()); |
| 27 | 0 | final List<HttpMessageConverter<?>> converters = Lists.newArrayList( |
| 28 | |
new ByteArrayHttpMessageConverter(), new StringHttpMessageConverter(), |
| 29 | |
new AllEncompassingFormHttpMessageConverter(), gsonHttpMessageConverter); |
| 30 | 0 | return new HttpMessageConverters() { |
| 31 | |
@Override |
| 32 | |
public List<HttpMessageConverter<?>> getConverters() { |
| 33 | 0 | return converters; |
| 34 | |
} |
| 35 | |
}; |
| 36 | |
} |
| 37 | |
} |