public void render(HttpServletRequest request, HttpServletResponse response) throws Exception {
response.setContentType("text/javascript;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = null;
try {
String json = JSON.toJSONString(this.getData(), SerializerFeature.WriteDateUseDateFormat);
//String json = JSON.toJSONString(this.getData(), SerializerFeature.UseISO8601DateFormat,SerializerFeature.UseSingleQuotes);
out = response.getWriter();
out.print(json);
} catch (IOException e) {
log.error("Controller response write JSON 出错!");
throw new RuntimeException("Controller response write JSON 出错!");
} finally {
out.close();
}
response.setContentType("text/javascript;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
PrintWriter out = null;
try {
String json = JSON.toJSONString(this.getData(), SerializerFeature.WriteDateUseDateFormat);
//String json = JSON.toJSONString(this.getData(), SerializerFeature.UseISO8601DateFormat,SerializerFeature.UseSingleQuotes);
out = response.getWriter();
out.print(json);
} catch (IOException e) {
log.error("Controller response write JSON 出错!");
throw new RuntimeException("Controller response write JSON 出错!");
} finally {
out.close();
}
}
主要主要标红的两句。设置编码格式