标签:
1.方法上面的RequestMapping要加上红色的部分。
@ResponseBody
@RequestMapping(value = "/search", produces = {"application/json;charset=UTF-8"})
public String search(HttpServletRequest request, HttpServletResponse response) {
2.推荐方式:在springmvc-servlet.xml[或者其他名称]里面更改<mvc:annotation-driven />的配置,如下:
把<mvc:annotation-driven />改成下面:
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8" />
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
springmvc 通过@ResponseBody 返回json的中文乱码解决方案2个
标签:
原文地址:http://www.cnblogs.com/aisam/p/4820054.html