JavaWeb下载文件特殊需求
红圈部分是消息头的处理
```java
resp.setContentType("text/html;charset=UTF-8");
//设置响应类型中包含文件附件
resp.setHeader("Content-Disposition", "attachment; " +
"filename=" + substring);
//4.获取下载文件的输入流
FileInputStream fis = new FileInputStream(path);
//5.创建缓冲区
int len = 0;
byte[] bytes = new byte[1024];
//6.获取outputstream
ServletOutputStream outputStream = resp.getOutputStream();
//7.将FileOutputStream写入缓冲区
while ((len = fis.read(bytes)) != -1){
outputStream.write(bytes, 0, len);
}
fis.close();
outputStream.close();