您的位置:首页 > Web前端 > JavaScript

解决IE下返回json数据提示文件保存到问题

2018-02-25 14:56 477 查看
在IE9,10,11下,当服务器端返回数据格式为json,且明确设置Content-Type为”application/json;charset=utf-8“时,会提示文件下载。如图所示:



解决方法

//发送的是JSON
public static void renderJson(HttpServletResponse response,String text){
render(response, "application/json;charset=UTF-8", text);
}
改为
//发送text
public static void renderText(HttpServletResponse response,String text){
render(response, "text/plain;charset=UTF-8", text);
}

//前段接收
success : function(result) {
//将text拼接为json
var result = eval('(' + result + ')');
if (result.message== 'ok') {

}else{

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐