前台访问网址: window.open('<%=request.getContextPath()%>/danger/danger/daochuExcel?fileName='+file,"_blank"); controller层: @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) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ file.delete(); } return null; }