测试下载文件名为:--@#¥%……&()——+-={}【】:;,..xls
时,服务端报错,IO异常。
原写法:
response.setHeader("Content-Disposition", "attachment; fileName=" + fileName);
解决写法
response.setHeader("Content-Disposition", "attachment;fileName*=UTF-8''" + UriUtils.encode(fileName, "UTF-8"));
UriUtils来自import org.springframework.web.util.UriUtils;
就可以正常下载了