java代码
@ResponseBody
@RequestMapping(value="/fileXiaz")
public ResponseEntity<byte[]> fileXiaz(HttpSession session) throws IOException {
System.out.println(fileId);
HttpHeaders headers = new HttpHeaders();
File file = new File("文件路径");//放文件路径
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); String
fileName = URLEncoder.encode(files.getFileName(),"utf-8");
headers.setContentDispositionFormData("attachment",fileName);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), headers, HttpStatus.CREATED);
}