使用response.setHeader("Content-Disposition","attachment;filename="+fName)下载文件,中文文件名无法显示

 这是部分代码
response.setContentType("application/msword");
String uncod= URLDecoder.decode(fileName);
fileName = new String(uncod.getBytes("UTF-8"), "UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=".concat(String.valueOf(fileName)));
这样写中文会丢失

改成如下
fileName = new String(uncod.getBytes(), "ISO-8859-1");
便可解决
posted @ 2020-07-02 10:02  很嚣张  阅读(2162)  评论(0)    收藏  举报