在spring的配置文件xml中
示例:
<!--注入枚举数組--> <bean id="writeMapNullValue" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"> <property name="staticField" value="com.alibaba.fastjson.serializer.SerializerFeature.WriteMapNullValue" /> </bean> <bean id="WriteNullStringAsEmpty" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean"> <property name="staticField" value="com.alibaba.fastjson.serializer.SerializerFeature.WriteNullStringAsEmpty" /> </bean> <bean id="fastJsonConfig" class="com.alibaba.fastjson.support.config.FastJsonConfig"> <property name="charset" value="utf-8" /> <property name="serializerFeatures" > <array> <ref bean="writeMapNullValue"/> <ref bean="WriteNullStringAsEmpty"/> </array> </property> </bean>