尝试了很多,有在controller的返回方法上面加:@RequestMapping(value = "allproduct",produces={"application/json;","text/html;charset=UTF-8;"})
也有:
<mvc:annotation-driven >
<!-- 消息转换器 -->
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="text/html;charset=UTF-8"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
以上都不好用
最后在springmvc的配置文件注解驱动:
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg ref="utf8Charset" />
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<bean id="utf8Charset" class="java.nio.charset.Charset" factory-method="forName">
<constructor-arg value="UTF-8" />
</bean>
完美解决