天天看點

JSON資料的中文亂碼問題

在 PrintWriter out = response.getWriter(); 

語句前使用

response.setContentType("text/json; charset=utf-8");

response.setCharacterEncoding("utf-8");

添加後代碼如下:

XXXAction.java :

View Code

String json = "{totalProperty:" + this.getTotalProperty() + ", start:"  
                    + this.getStart() + ", limit:" + this.getLimit() + ", root:"  
                    + listStudent.toString() + "}";  
    this.getResponse().setContentType("text/json; charset=utf-8");  
    this.getResponse().setCharacterEncoding("utf-8");   
    super.outPrint(json);       
    System.out.println(json);  // 列印出來看看效果  
    super.setContentType(BaseAction.JSON);        

轉載于:https://www.cnblogs.com/zsz198908/archive/2013/01/21/2869942.html

上一篇: valgrind for arm