zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    springMVC controller输出前台提示信息
    使用ionic3开始自己的App开发之路
    async await
    mongodb安装和启动
    express框架的安装和使用
    js继承的实现方式
    node版本管理
    git提交时冲突问题解决
    css推荐
    js工具推荐
  • 原文地址:https://www.cnblogs.com/denggelin/p/8406865.html
Copyright © 2011-2022 走看看