java下载中文文件名乱码的解决方法

在后台响应前台下载请求时,输出到前台的下载文件名(在FF中显示一大串乱码)

原代码:

StringsaveAsFileName = URLEncoder.encode(saveAsFileName, "UTF-8");

response.addHeader("Content-Disposition","attachment;filename="+saveAsFileName );

改成:

StringsaveAsFileName =newString(saveAsFileName getBytes("GBK"), "ISO8859_1");

response.addHeader("Content-Disposition","attachment;filename="+saveAsFileName );

解决。。。

你可能感兴趣的:(java)