日期:2014-05-19 浏览次数:21069 次
try {
// fileName = new String(fileName.getBytes("UTF-8"), "UTF-8");
//if (request.getHeader("User-Agent").toLowerCase().indexOf("firefox") > 0)
fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
// else
//
// if (request.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0)
//
// fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
} catch (UnsupportedEncodingException e) {
// should no happen
}
System.out.println(fileName);
response.reset();
response.setContentType("application/msexcel;charset=UTF-8");
response.setHeader("Content-disposition", "attachment;filename= " + fileName);
}
------解决方案--------------------
String downloadName = "表名.xls";
downloadName = new String(downloadName.getBytes(), "ISO8859-1");
response.setHeader("Content-disposition", "attachment;filename=" + downloadName);
response.setContentType("application/x-download");
ServletOutputStream servletOutputStream = response.getOutputStream();
wb.write(servletOutputStream);
servletOutputStream.flush();
servletOutputStream.close();