java Resource下文件下载
/**
* 文件下载,根据文件名,在Resource文件夹下读取文件,设置报文头,response响应文件流。
* @param response
* @param fileName
* @throws Exception
*/
public static void downFile(HttpServletResponse response, String fileName) throws Exception{
ClassPathResource classPathResource = new ClassPathResource(fileName);
InputStream inputStream=classPathResource. getInputStream();
response.setHeader("Content-Disposition", "attachment;filename*=utf-8'zh_cn'"+
URLEncoder.encode (fileName,"UTF-8""));
response.setHeader("Connection","close");
response.setHeader("Content-Type", "application/octet-stream");
IOUtils.copy(inputStream, response.getOutputStream());
}