window.open('<%=request.getContextPath()%>/danger/danger/daochuExcel?fileName='+file,"_blank");
@RequestMapping(value="/daochuExcel")
public String daochuExcel(HttpServletResponse response, String fileName) throws UnsupportedEncodingException{
File file =new File(pathExcel+fileName);
byte[] bb = FileUtils.getBytesFromFile(file);
response.setContentType("application/msexcel");
response.setContentType("application/octet-stream");
response.addHeader("Content-Disposition", "attachment; filename=" +
URLEncoder.encode(file.getName(),"UTF-8"));
ServletOutputStream out;
try {
out = response.getOutputStream();
out.write(bb);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}finally{
file.delete();
}
return null;
}