Spring MVC整合fastjson、EasyUI乱码问题

一、框架版本

Spring MVC:spring-webmvc-4.0.0.RELEASE

fastjson:fastjson-1.2.45

EasyUI:1.5

二、乱码现象

Controller调用方法,输出到浏览器,出现乱码

1     @ResponseBody
2     @RequestMapping("/getManyEducation")
3     public String getManyCategory() {
4         List<Education> es = educationService.list();
5 
6         return JSONObject.toJSON(es).toString();
7     }

三、解决办法

在Controller类的注解@RequestMapping加上produces = "text/html;charset=UTF-8",问题解决

 1 //告诉spring mvc这是一个控制器类
 2 @Controller
 3 @RequestMapping(value = "", produces = "text/html;charset=UTF-8")
 4 public class EducationController {
 5     @Autowired
 6     EducationService educationService;
 7 
 8     @ResponseBody
 9     @RequestMapping("/getManyEducation")
10     public String getManyCategory() {
11         List<Education> es = educationService.list();
12 
13         return JSONObject.toJSON(es).toString();
14     }
15 
16 }
原文地址:https://www.cnblogs.com/denggelin/p/8406865.html