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);  

 

posted @ 2013-01-21 16:13  竹子198908  阅读(617)  评论(0编辑  收藏  举报