1.下载文件首先需要在jsp页面把文件的地址传到后端
public void downloads(HttpServletRequest request, HttpServletResponse response, String url) throws Exception {
String strUrl = url;
int i = 29;
String urlstr = url.substring(i);
System.out.println("#########################___" + urlstr);
InputStream bis = new BufferedInputStream(new FileInputStream(new File(strUrl)));
String filename = urlstr;
filename = URLEncoder.encode(filename, "UTF-8");
response.addHeader("Content-Disposition", "attachment;filename=" + filename);
response.setContentType("multipart/form-data");
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
int len = 0;
while ((len = bis.read()) != -1) {
out.write(len);
out.flush();
}
out.close();
}