Java++:防止下载文件名中存在特殊字符导致下载出错

测试下载文件名为:--@#¥%……&()——+-={}【】:;,..xls

时,服务端报错,IO异常。

原写法:

response.setHeader("Content-Disposition", "attachment; fileName=" + fileName);

解决写法:

response.setHeader("Content-Disposition", "attachment;fileName*=UTF-8''" + UriUtils.encode(fileName, "UTF-8"));
原文地址:https://www.cnblogs.com/codingmode/p/13804265.html