FastJson 직렬화 역직렬화 방법
FastJsonHttpMessageConverter
# 🎜🎜## 🎜🎜#
FastJson은 Spring MVC HttpMessageConverter의 구현을 제공합니다
FastJsonHttpMessageConverter for Spring MVC 4.2 이하 #🎜 🎜## 🎜🎜#Spring MVC 4.2+용 FastJsonHttpMessageConverter4
- Spring Controller에서 FastJson을 사용하여 데이터를 직렬화 및 역직렬화하는 데 사용할 수 있습니다FastJsonConfig 구성#🎜🎜 ## 🎜 🎜#
<bean id="fastJsonConfig" class="com.alibaba.fastjson.support.config.FastJsonConfig"> <!-- Default charset --> <property name="charset" value="UTF-8" /> <!-- Default dateFormat --> <property name="dateFormat" value="yyyy-MM-dd HH:mm:ss" /> <!-- Feature --> <property name="features"> <list> <value>Your feature</value> </list> </property> <!-- SerializerFeature --> <property name="serializerFeatures"> <list> <value>Your serializer feature</value> </list> </property> <!-- Global SerializeFilter --> <property name="serializeFilters"> <list> <ref bean="Your serializer filter"/> </list> </property> <!-- Class Level SerializeFilter --> <property name="classSerializeFilters"> <map> <entry key="Your filter class" value-ref="Your serializer filter"/> </map> </property> </bean>
HttpMessageConverter 구성
<mvc:annotation-driven> <mvc:message-converters> <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"> <!-- MediaTypes --> <property name="supportedMediaTypes"> <list> <value>application/json</value> </list> </property> <!-- FastJsonConfig --> <property name="fastJsonConfig" ref="fastJsonConfig" /> </bean> </mvc:message-converters> </mvc:annotation-driven> <mvc:default-servlet-handler />#🎜 🎜## 🎜🎜 #