版本1.2.41配置FastJsonpResponseBodyAdvice后,jsonp请求返回数据中文乱码, 如果不是jsonp请求就不会乱码! ` @Configuration public class FastJsonConverterConfig extends WebMvcConfigurerAdapter { @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { //创建fastJson的消息转换器 FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter(); //创建配置类 FastJsonConfig fastJsonConfig = new FastJsonConfig(); //修改配置返回内容的过滤 fastJsonConfig.setSerializerFeatures( SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.DisableCircularReferenceDetect ); //配置时间转换 SerializeConfig serializeConfig = new SerializeConfig(); String dateFormat = "yyyy-MM-dd HH:mm:ss"; serializeConfig.put(Timestamp.class, new SimpleDateFormatSerializer(dateFormat)); fastJsonConfig.setSerializeConfig(serializeConfig); //处理中文乱码问题 List fastMediaTypes = new ArrayList<>(); fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8); //消息转换器装载中文乱码配置 fastJsonHttpMessageConverter.setSupportedMediaTypes(fastMediaTypes); //消息转换器装载fastJson配置 fastJsonHttpMessageConverter.setFastJsonConfig(fastJsonConfig); converters.add(fastJsonHttpMessageConverter); //调用父类的配置 super.configureMessageConverters(converters); }
@Bean
public FastJsonpResponseBodyAdvice fastJsonpResponseBodyAdvice() {
return new FastJsonpResponseBodyAdvice();
}
}`