fastjson配置序列化过滤转换
2021-01-18 02:13
标签:port tpm enable ide util ica public new list @Override FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter(); } fastjson配置序列化过滤转换 标签:port tpm enable ide util ica public new list 原文地址:https://www.cnblogs.com/AnonymouL/p/13354158.html
@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
public void configureMessageConverters(List
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializeFilters(new ValueFilter() {
@Override
public Object process(Object object, String name, Object value) {
if (value == null){
return "";
}
if (value instanceof Date){
return DateUtils.formatDate((Date) value,"yyyy-MM-dd hh:mm:ss");
}
return value;
}
});
fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig);
List
mediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
fastJsonHttpMessageConverter.setSupportedMediaTypes(mediaTypes);
converters.add(fastJsonHttpMessageConverter);
}