文件下载header设置

BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
// 设置响应头和下载保存的文件名
if (extendName != null) {
mimeType = this.getServletContext().getMimeType(extendName);
}
if (mimeType == null) {
mimeType = "APPLICATION/OCTET-STREAM";
}
response.setContentType(mimeType);
response.setHeader("Content-Disposition", "attachment; filename=\"" + new String(displayName.getBytes(), "ISO-8859-1") + "\"");

你可能感兴趣的:(File,mimetype)