/**
*@paramresponse
*@paramdownloadFile
*/
privatevoidclientResponse(HttpServletResponseresponse,FiledownloadFile,StringfileName){
try{
response.reset();
response.setContentType("application/octet-stream");
//用来弹出保存窗口,设置为attachment
response.setHeader("Content-Disposition","attachment;filename="+newString(fileName.getBytes(),"ISO-8859-1"));
InputStreaminput=newFileInputStream(downloadFile);
OutputStreamoutput=response.getOutputStream();
intc;
//读取流并写入到文件中
while((c=input.read())!=-1){
output.write(c);
}
output.flush();
output.close();
input.close();
}catch(Exceptione){
}
}
<iframe id="download" name="download" height="0px" width="0px"></iframe>
<base target="download">