ajax返回json格式时,中文乱码问题,以问号形式呈现

来源:互联网 发布:小米6相机优化 编辑:程序博客网 时间:2024/06/07 21:56

解决方案:将json格式用response设置编码后输出

Map<String,Object> resultMap = new HashMap<String, Object>();resultMap.put("downloadSoftUrl", downloadSoftUrl);resultMap.put("hotKeys", hotKeyList);resultMap.put("isClose", isClose);String jsonResult = JSON.toJSONString(resultMap, true);//解决json前端乱码问题response.setContentType("text/html;charset=UTF-8");response.getWriter().print(jsonResult);


0 0