文件下载 响应头获取中文名称乱码问题解决方法


   后端设置:

// 下载文件能正常显示中文
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(attachment.getAttachmentName(), "UTF-8"));
response.setCharacterEncoding("UTF-8");

前端设置:

var fileName = decodeURI(disposition.split(";")[1].split("filename=")[1]);