使用http协议下:
response.setContentType(
"application/octet-stream; name=\"" + fileName + "\"");
response.setHeader("Content-Disposition",
"attachment; filename=\"" + fileName + "\"");
既可以在http协议下,又可以在https协议下下载
response.setHeader("Expires", "0");
response.setHeader("Pragma", "public");
response.setHeader("Cache-Control",
"must-revalidate, post-check=0, pre-check=0");
response.setHeader("Cache-Control", "public");
response.setContentType(
"application/octet-stream; name=\"" + fileName + "\"");
response.setHeader("Content-Disposition",
"attachment; filename=\"" + fileName + "\"");
注意:在使用struts框架的情况下,一定不要再return重定向字符串
应该如下操作:return success ==>return “”;