String realName = "设置的文件名";
response.setContentType("application/octet-stream; charset=UTF-8");
if (StrUtil.isNotBlank(realName)) {
// 设置文件名
String disposition = "attachment; filename=" + URLEncoder.encode(realName, "UTF-8");
// 设置下载文件名称
response.setHeader("Content-Disposition", disposition);
}
参考地址:
https://blog.51cto.com/u_16175484/7060931
https://blog.51cto.com/u_16175508/7117382