|
|
|
@ -49,9 +49,11 @@ public class WebMvcConfigurer extends WebMvcConfigurerAdapter { |
|
|
|
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { |
|
|
|
|
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); |
|
|
|
|
FastJsonConfig config = new FastJsonConfig(); |
|
|
|
|
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue,//保留空的字段
|
|
|
|
|
SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
|
|
|
|
|
SerializerFeature.WriteNullNumberAsZero);//Number null -> 0
|
|
|
|
|
config.setSerializerFeatures(SerializerFeature.WriteMapNullValue);//保留空的字段
|
|
|
|
|
//SerializerFeature.WriteNullStringAsEmpty,//String null -> ""
|
|
|
|
|
//SerializerFeature.WriteNullNumberAsZero//Number null -> 0
|
|
|
|
|
// 按需配置,更多参考FastJson文档哈
|
|
|
|
|
|
|
|
|
|
converter.setFastJsonConfig(config); |
|
|
|
|
converter.setDefaultCharset(Charset.forName("UTF-8")); |
|
|
|
|
converters.add(converter); |
|
|
|
|