最近在改一个原来的邮件系统,原来系统的附件是二进制,我从数据库拿出来只能是个byte[],我将其用new ByteArrayInputStream(unZip)转化为intputStream,然后通过struts2下载,以为不是FileInputStream,在客户端全部都被直接打开了,各位大神有什么解决办法
配置文件:
image/png,image/jpeg,image/gif,text/plain
4096
filename=${fileName}
action中代码:
public String findFile() throws Exception {
byte[] b = mailService.findFile(msgid, num,mailSt);
byte[] unZip = unZip(b);
HttpServletResponse resp = ServletActionContext.getResponse();
resp.setCharacterEncoding("text/html;charset=GBK");
this.inputStream = new ByteArrayInputStream(unZip);
return "stream";
}