springmvc整合fastjson

xiaoxiao2021-02-28  68

fastjson文档: https://github.com/alibaba/fastjson/wiki jar: fastjson-1.2.32,spring 4.2+

springmvc配置

<!-- 配置Fastjson支持 --> <bean id = "fastJsonConfig" class="com.alibaba.fastjson.support.config.FastJsonConfig"> <property name="serializerFeatures"> <list> <value>QuoteFieldNames</value> <value>WriteMapNullValue</value> <value>WriteNullNumberAsZero</value> <value>WriteNullListAsEmpty</value> <value>WriteNullStringAsEmpty</value> <value>WriteNullBooleanAsFalse</value> </list> </property> <property name="dateFormat" value="yyyy-MM-dd HH:mm:ss"></property> </bean> <mvc:annotation-driven> <mvc:message-converters register-defaults="true"> <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> </list> </property> <property name="fastJsonConfig" ref="fastJsonConfig"/> </bean> </mvc:message-converters> </mvc:annotation-driven>
转载请注明原文地址: https://www.6miu.com/read-37286.html

最新回复(0)