java下载时,文件名含有"/",进行编码后 文件名显示中"/"显示成"-"ie为"_",怎么才能显示正确呢
response.setHeader("Content-Disposition",String.format("attachment;filename=\"%s\"",n...
response.setHeader("Content-Disposition", String.format("attachment; filename=\"%s\"", name));
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setCharacterEncoding("UTF-8");
encode代码:
if (userAgent.contains("MSIE")||userAgent.contains("Trident")) { //针对IE或者以IE为内核的浏览器:
name = URLEncoder.encode(name, "UTF-8");
} else {//非IE浏览器的处理:
name = new String(name.getBytes("UTF-8"),"ISO-8859-1");
} 展开
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setCharacterEncoding("UTF-8");
encode代码:
if (userAgent.contains("MSIE")||userAgent.contains("Trident")) { //针对IE或者以IE为内核的浏览器:
name = URLEncoder.encode(name, "UTF-8");
} else {//非IE浏览器的处理:
name = new String(name.getBytes("UTF-8"),"ISO-8859-1");
} 展开
2个回答
2016-06-22
展开全部
文件名中,允许使用/么??????
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询