本文共 606 字,大约阅读时间需要 2 分钟。
后台代码。@RequestMapping("downLoad")public ResponseEntitydownloadPromisePdf() { String fileName = "企业诚信守法承诺书.pdf"; try { byte[] pdf = **;//byte文件 String dfileName = new String(fileName.getBytes("gb2312"), "iso8859-1"); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); headers.setContentDispositionFormData("attachment", dfileName); return new ResponseEntity<>(pdf, headers, HttpStatus.OK); } catch (BuzEx e){ logger.error( e.getMessage()); }catch (Exception e) { } return null;}
前端直接window.location.href='/downLoad';
转载地址:http://plvbi.baihongyu.com/