工作问题:http下载文件,中文文件名在firefox下乱码问题

以下博文转自 wen66.iteye.com/blog/2067678

http 下载文件时,中文文件名在firefox下乱码的问题,一般在http header中是这样操作的:
"Content-Disposition","attachment;filename=文件名.xx"  



其实,按照  rfc231 , Content-Disposition 应该按照如下格式设置:
"Content-Disposition","attachment;filename*=utf-8'zh_cn'文件名.xx"  



只要严格按照标准设置以后,自然在各种浏览器下都会正常运行了.

目前测试在
ff 29
chrome 33
IE     11

下都是正常的.
完整的java代码如下:
response.setHeader("content-disposition", String.format("attachment;filename*=utf-8'zh_cn'%s.xls",URLEncoder.encode("插入失败员工记录""utf-8"))); 

猜你喜欢

转载自hus2013.iteye.com/blog/2244030
今日推荐