首页>代码>Spring Boot+SpringData JPA整合实现用户增删改查及其分页查询简单实战项目>/SpringDataJPA-master/src/main/java/com/vcyber/FastJsonConfiguration.java
package com.vcyber; import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.support.config.FastJsonConfig; import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import java.util.ArrayList; import java.util.List; /** * ======================== * Created with IntelliJ IDEA. * ======================== */ @Configuration public class FastJsonConfiguration extends WebMvcConfigurerAdapter { /** * 修改自定义消息转换器 * @param converters 消息转换器列表 */ @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { //调用父类的配置 super.configureMessageConverters(converters); //创建fastJson消息转换器 FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter(); //创建配置类 FastJsonConfig fastJsonConfig = new FastJsonConfig(); //修改配置返回内容的过滤 fastJsonConfig.setSerializerFeatures( SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullStringAsEmpty ); //解决中午乱码 List<MediaType> fastMediaTypes = new ArrayList<>(); fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8); fastConverter.setSupportedMediaTypes(fastMediaTypes); fastConverter.setFastJsonConfig(fastJsonConfig); //将fastjson添加到视图消息转换器列表内 converters.add(fastConverter); } }

Demo1111 LV30
2023年12月7日
微信网友_6108289352863744 LV4
2022年8月31日
龙门客栈 LV9
2021年12月19日
updayxkk LV2
2021年10月30日
icesolitude LV8
2021年10月13日
253702090 LV3
2021年8月15日
珈文迪许 LV7
2021年5月4日
kkkkk666 LV10
2021年2月19日
gshnlj LV15
2020年10月14日
xjsdn786 LV2
2020年7月24日

dane168 LV8
2月17日
17380184110
2024年6月18日
暂无贡献等级
ma406805131 LV19
2024年5月11日
飃go with wind
2024年5月7日
暂无贡献等级
沈从文 LV3
2024年1月1日
oulingqiao LV13
2023年12月12日
fff2003 LV9
2023年11月17日
601601lmy LV5
2023年10月20日
漫步的海星 LV4
2023年9月21日
飞呀飞呀飞不放 LV7
2023年8月9日