<!-- 会自动注册了validator ConversionService -->
<mvc:annotation-driven>
<!--enableMatrixVariables="true">-->
<mvc:message-converters register-defaults="true">
<!-- StringHttpMessageConverter编码为UTF-8,防止乱码 -->
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8"/>
<property name="supportedMediaTypes">
<list>
<bean class="org.springframework.http.MediaType">
<constructor-arg index="0" value="text"/>
<constructor-arg index="1" value="plain"/>
<constructor-arg index="2" value="UTF-8"/>
</bean>
<bean class="org.springframework.http.MediaType">
<constructor-arg index="0" value="*"/>
<constructor-arg index="1" value="*"/>
<constructor-arg index="2" value="UTF-8"/>
</bean>
</list>
</property>
</bean>
<!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->
<bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter"
id="fastJsonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-8</value>
</list>
</property>
<!--<property name="serializerFeature">-->
<!--这个地方加上这个功能吧,能自己配置一些东西,比如时间的格式化,null输出""等等-->
<!--</property>-->
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
fastJson与springmvc结合,在spring-mvc.xml中的配置,解决415报错
最新推荐文章于 2022-08-21 17:01:10 发布