spring mvc 3.1.8 ajax返回值乱码处理问题

tomatoboryj 2013-07-19

spring-servlet.xml中配置

<!-- 处理ajax返回值时候乱码 -->

<mvc:annotation-driven>

<mvc:message-converters register-defaults="true">

<bean class="org.springframework.http.converter.StringHttpMessageConverter">

<property name="supportedMediaTypes" value="text/plain;charset=UTF-8" />

</bean>

</mvc:message-converters>

</mvc:annotation-driven>

ajax方法上写

@RequestMapping(value = "/list.do", produces = "text/plain; charset=UTF-8")

@ResponseBody

public String list(PtDataUserDO entity) throws Exception {

注意两个地方都需要注明utf-8,缺一不起作用。网上给的答案恶心死我了。

相关推荐

mmywcoco / 0评论 2020-06-06