@RequestMapping(value = "downLoad")
@ResponseBody
public void downLoad(String path, HttpServletResponse response) {
try {
if(path == null || path.length() == 0) {
throw new BusinessException("请重新上传照片");
}
//path = "http://localhost:8084/file2/1.jpg";
int index = path.lastIndexOf("/");
String name = path.substring(index+1);
String url="D:/home/share2/"+name;
File file = new File(url);
FileImageInputStream fs = new FileImageInputStream (file);
int streamLength = (int)fs.length();
byte[] image = new byte[streamLength ];
fs.read(image,0,streamLength );
fs.close();
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename="+name);
response.getOutputStream().write(image );
response.getOutputStream().flush();
response.getOutputStream().close();
} catch (IOException ex) {
ex.printStackTrace();
}
//return response;
}