经过作者亲测, 4.2.2 版本有问题。 4.2.1.RELEASE 4.2.3.RELEASE 4.2.5.RELEASE 4.3.5.RELEASE 均未出现下载文件的情况。
以下是作者本人 fastjson 整合 springmvc 的配置文件 部分配置
<mvc:annotation-driven>
<mvc:message-converters>
<!-- fastjson 版本号 1.2.23 spring版本4.2(+) -->
<bean id="fastJsonHttpMessageConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>text/json;charset=UTF-8</value>
<!-- <value>application/json;charset=UTF-8</value>
<value>application/xml;charset=UTF-8</value> -->
</list>
</property>
<property name="fastJsonConfig">
<bean class="com.alibaba.fastjson.support.config.FastJsonConfig">
<property name="features">
<list>
<value>AllowArbitraryCommas</value>
<value>AllowUnQuotedFieldNames</value>
<value>DisableCircularReferenceDetect</value>
</list>
</property>
<property name="dateFormat" value="yyyy-MM-dd HH:mm:ss"></property>
</bean>
</property>
</bean>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg>
<bean class="java.nio.charset.Charset" factory-method="forName">
<constructor-arg value="UTF-8"/>
</bean>
</constructor-arg>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>