文件下载Content-Disposition中文乱码

 

String fileName = "中国.doc";
//方法1:
response.setHeader("Content-Disposition", "attachment; filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));

//方法2:使用指定编码,并告诉浏览器编码类型
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + URLEncoder.encode(fileName, "UTF-8");

//方法3:
response.setHeader("Content-Disposition", "attachment; filename=" + new String(fileName.getBytes("gb2312"), "ISO-8859-1")); 

 

 

 

你可能感兴趣的:(文件下载Content-Disposition中文乱码)