String fileName = "产品项目列表-" + DateUtils.format(new Date()) + ".xlsx";
1、
response.setHeader("Content-disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
2、
response.setHeader("Content-disposition", "attachment;filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
3、有空格时 使用
String replaceStr = URLEncoder.encode(fileName, "utf-8").replace("\\+", "%20");
// 组装contentDisposition的值
String contentDispositionValue = "attachment; filename=" +
replaceStr +
"; filename*= utf-8''" +
replaceStr;
response.setHeader("Content-disposition", contentDispositionValue);
版权声明:本文为u012002805原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。