firefox 文件下载 中文乱码 解决办法
给你个例子
<%@ 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){
}
%>
<%@ 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){
}
%>