美文网首页
SpringMvc中导出excel时文件名中文乱码问题

SpringMvc中导出excel时文件名中文乱码问题

作者: BestbpF | 来源:发表于2018-08-07 17:57 被阅读32次

问题描述

在使用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");

原因

有待了解

相关文章

网友评论

      本文标题:SpringMvc中导出excel时文件名中文乱码问题

      本文链接:https://www.haomeiwen.com/subject/jjiavftx.html