代码改变世界

Ext 表单提交

2019-10-16 16:57  yt1006574924  阅读(121)  评论(0编辑  收藏  举报
1.String outFileName = "中文乱码+".xls";
resp.reset();
resp.setHeader("Content-Disposition","attachment;filename="+ new String(outFileName.getBytes(),"ISO-8859-1"));
//1.设置文件ContentType类型,这样设置,会自动判断下载文件类型
resp.setContentType("application/octet-stream;charset=UTF-8");
// 以流的形式下载文件
//读取文件
InputStream in = new FileInputStream(outFilePath);
ServletOutputStream outputStream = resp.getOutputStream();
//写文件
int b;
while((b=in.read())!= -1)
{
outputStream.write(b);
}
in.close();
outputStream.close();
out.close();

2.IE上提交参数含中文时需要转译,使用encodeURIComponent