response.setContentType("application/x-download");//设置为下载application/x-download String filedownload = "E:/"+fileName; //即将下载的文件的相对路径 String filedisplay = "最终要显示给用户的保存文件名";//下载文件时显示的文件保存名称 String filenamedisplay = URLEncoder.encode(filedisplay,"UTF-8"); response.addHeader("Content-Disposition","attachment;filename=" + filedisplay);