Java|Java基础
java,乱码
Java-Java基础
在线微信墙html5源码,vscode编辑图片,ubuntu分辨率怎么设置,tomcat代理配置,sqlite 左连接,网页设计教程推荐,mysql数据库升级,云服务器ecs修改远程密码,wordpress 过滤插件,前端3大框架选型,shell爬虫,php错误日志,舟山SEO,springboot挡板,织梦开启php标签,手机树洞网站源码,网页游戏开发论坛,微信微商城模板下载不了,网站后台灰色,聊天页面 html,织梦内容管理系统图片,asp彩票程序lzw
出现的问题:在chrome浏览器中导出的excel文件名没有出现中文乱码的情况,在测试IE浏览器的时候,导出的文件名乱码了。
人事工资管理系统源码,vscode 文本编辑器,ubuntu 命令mv,tomcat下的html,python 爬虫 速度,php 开发手机应用,浦城一般seo服务电话,易思网站管理系统lzw
解决方法:
淘客采集商品库网站源码,ssh连接ubuntu图形,连接tomcat要网吗,厕所小型爬虫,php教程技巧交流,和平区好的seo推广哪家强lzw
原来的代码:
try { response.setContentType("application/vnd.ms-excel;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); response.addHeader("Content-Disposition", "attachment;filename=" + new String((edTemplate.getTemplateName() + "导入模板").getBytes(), "ISO-8859-1") + ".xls"); OutputStream os = response.getOutputStream(); workbook.write(os); os.flush(); os.close(); } catch (IOException e) { e.printStackTrace(); return ResponseMsgUtil.failure(); }
在new String((edTemplate.getTemplateName() + “导入模板”).getBytes(), “ISO-8859-1”) 的getBytes()这个方法里加上一个编码
修改后的代码
try { response.setContentType("application/vnd.ms-excel;charset=UTF-8"); response.setCharacterEncoding("UTF-8"); response.addHeader("Content-Disposition", "attachment;filename=" + new String((edTemplate.getTemplateName() + "导入模板").getBytes("gb2312"), "ISO-8859-1") + ".xls"); OutputStream os = response.getOutputStream(); workbook.write(os); os.flush(); os.close(); } catch (IOException e) { e.printStackTrace(); return ResponseMsgUtil.failure(); }
更多java知识请关注java基础教学栏目。