最开始是这样的,结果在火狐下一直报错
Boolean flag= request.getHeader("User-Agent").indexOf("like Gecko")>0;
if (request.getHeader("User-Agent").toLowerCase().indexOf("msie") >0||flag){
fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
}else {
fileName = new String(fileName.getBytes(), "iso-8859-1");
}
response.setHeader("Content-Disposition", "attachment; filename="+ new String(fileName.getBytes(), "iso-8859-1"));
后来直接在header里做设置,如下,就好了
response.addHeader("Content-Disposition", new String(("attachment; filename=" + fileName).getBytes("GBK"), "ISO-8859-1"));
参见:http://blog.csdn.net/hi_kevin/article/details/8004471