public String downloadSecModel() throws ApplicationException {
if (vouchId != null) {
String url = imgUrl; //获取图片的URL
try {
this.getResponse().setHeader("Content-disposition", "attachment;filename=" + vouchId + ".jpg"); // vouchId 图片命名
FileInputStream finput = new FileInputStream(url);
BufferedInputStream buffin = new BufferedInputStream(finput);
OutputStream output = this.getResponse().getOutputStream();
BufferedOutputStream buffout = new BufferedOutputStream(output);
byte[] buffer = new byte[4096];
int count = 0;
while ((count = buffin.read(buffer, 0, buffer.length)) > 0) {
buffout.write(buffer, 0, count);
}
output.flush();
buffin.close();
buffout.close();
finput.close();
output.close();
} catch (Exception e) {
e.printStackTrace();
}
return SUCCESS;
} else {
return ERROR;
}
}
<result name="success">
</result>
<!-图片可以正常下载,但是后台会报错误,还没解决-->