firefox 文件下载 中文乱码 解决办法

it2022-05-09  24

给你个例子 <%@ page import="java.io.FileInputStream" %> <%@ page import="java.io.InputStream" %> <%@ page import="java.io.OutputStream" %> <% response.reset(); response.setContentType("application/vnd.ms-excel"); String exportName = "一个excel.xls"; response.setHeader("Content-Disposition", "attachment;filename=" + new String(exportName.getBytes("GBK"), "iso8859-1")); String path=application.getRealPath("/")+"/download/aa.xls"; System.out.println("giftimport.xls path:"+path); try{ InputStream is=new FileInputStream(path); OutputStream os=response.getOutputStream(); int read=0; while((read=is.read())!=-1){ os.write(read); } os.flush(); os.close(); }catch(Exception e){ } %>

转载于:https://www.cnblogs.com/nanshouyong326/archive/2008/06/27/1231190.html

相关资源:数据结构—成绩单生成器

最新回复(0)