---
title: "工作问题:http下载文件,中文文件名在firefox下乱码问题"
author: "HUS2013"
date: "2015-09-16T18:12:46Z"
tags: []
categories: ["互联网"]
slug: "http-firefox"
draft: false
lastmod: "2015-09-16T18:12:46Z"
id: 2244030
url: "https://hus2013.iteye.com/blog/2244030"
---

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

 

 

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

其实,按照  [rfc231](http://tools.ietf.org/html/rfc2231) , 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")));