springmvc文件下载
时间:2021-12-14 作者:匿名
@RequestMapping("/download") public void download(HttpServletResponse res ,HttpServletRequest req) throws IOException { OutputStream os = 域名utputStream(); try { 域名t(); 域名eader("Content-Disposition", "attachment; filename=域名"); 域名ontentType("application/octet-stream; charset=utf-8"); 域名e(域名FileToByteArray(getDictionaryFile(req))); 域名h(); } finally { if (os != null) { 域名e(); } } } private File getDictionaryFile(HttpServletRequest req) { File file =new File(域名ession().getServletContext().getRealPath("/WEB-INF/域名")); return file; }
http://域名/topic/1125784