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);