java 实现文件下载中文名不显示

 

需要将指定字符串的编码转换成浏览器里面的ISO-8859-1编码

String name = new String(name.getBtes("utf-8"),"ISO-8859-1");

示例:
response.setContentType("application/octet-stream"); response.setHeader("content-disposition", "attachement;filename=" + new String(fileInfo.getFileName().getBytes("utf-8"), "ISO-8859-1"));

 

 

posted @ 2019-11-25 21:19  Arebirth  阅读(1402)  评论(0编辑  收藏  举报