问题描述
在使用springmvc导出Excel时,设置response响应头如下
response.setHeader("Content-Disposition", "attachment;filename=测试.xls");
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setCharacterEncoding("UTF-8");
下载excel后文件名称乱码
解决方法
response.setHeader("Content-Disposition", "attachment;filename*=UTF-8''" + URLEncoder.encode(fileName,"UTF-8"));
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setCharacterEncoding("UTF-8");
原因
有待了解