- if(request.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0) {
- response.setHeader("Content-Disposition","attachment;"+ "filename="+ new
- String(filename.getBytes("GBK"),"ISO8859-1"));
- }else{//firefox、chrome、safari、opera
- response.setHeader("Content-Disposition","attachment;"+
- "filename="+ new String(filename.getBytes("UTF8"), "ISO8859-1") );
- }
- 代码为复制某位大神的、但解决了我的问题。根本问题为浏览器只支持ISO8859-1编码。
http文件下载-文件名(汉字)乱码解决代码
最新推荐文章于 2023-10-16 14:51:40 发布