有关java导出excel的中文编码的问题---response.setHeader()

excel文件名是中文,然后导出的文件名是一串“-------.xls”,问题出在这里
response.setHeader("Content-disposition", "attachment; filename=“中文”.xls)
后来解决了,改为
String zhStr= "中文";
String fileName = null;
try {
/*根据request的locale 得出可能的编码,中文操作系统通常是gb2312*/
   fileName = new String(as.getBytes("GB2312"), "ISO_8859_1");
} catch (UnsupportedEncodingException e) {
   e.printStackTrace();
}
zhStr=fileName;
response.setHeader("Content-disposition","attachment; filename="+zhStr+".xls");;

 




posted @ 2017-02-28 11:00  daidao  阅读(4890)  评论(0)    收藏  举报