有关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");;

 





免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM