由于项目需要,导出txt文件,但导出的文件名只能是英文和数字,中文名称是乱码,现提供正常导出中文文件名的方法
只需添加new String(fileName.getBytes("gb2312"), "iso8859-1"))进行中文名称转换即可
response.setContentType("text/plain;charset=GBK");
response.setHeader("Content-disposition", "attachment; filename="+new String(fileName.getBytes("gb2312"), "iso8859-1"));
只需添加new String(fileName.getBytes("gb2312"), "iso8859-1"))进行中文名称转换即可