Java文件下载文件名包含特殊字符处理

2,247 阅读1分钟
response.setCharacterEncoding("UTF-8");
            response.setContentType("multipart/form-data");
            response.setHeader("Content-Disposition",
                    "attachment;fileName*=UTF-8''" + UriUtils.encode(fileName, "UTF-8"));

重点是fileName*=UTF-8'' 和UriUtils.encode,UriUtils使用的是spring包的org.springframework.web.util.UriUtils

以上