下载 /** * 下载 pdf * @param id * @param table * @return */ @RequestMapping("/donloadpdf") @ResponseBody public ResponseEntity donloadpdf( String id ,String table ) { logger.info("donloadpdf 进入web开始下载 pdf"); try { String pdf
/** * 下载 pdf * @param id * @param table * @return */ @RequestMapping("/donloadpdf") @ResponseBody public ResponseEntity上传donloadpdf( String id ,String table ) { logger.info("donloadpdf 进入web开始下载 pdf"); try { String pdfpath = null; if ("notice".equals(table)){ TfLawNotice notice = (TfLawNotice) queryID(id).get(0); pdfpath = notice.getPdfpath(); }else if("sued".equals(table)){ TfLawSued sued = (TfLawSued) querySuedID(id).get(0); pdfpath = sued.getPdfpath(); } File file = new File(pdfpath); HttpHeaders headers = new HttpHeaders(); String filename = new String(file.getName().getBytes("utf-8"), "ISO-8859-1"); headers.setContentDispositionFormData("attachment",filename ); headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); logger.info("donloadpdf 结束下载 pdf"); return new ResponseEntity (FileUtils.readFileToByteArray(file), headers, HttpStatus.CREATED); } catch (Exception e) { e.printStackTrace(); } return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); }
/* springboot 上传 @RequestParam("pdfpath") MultipartFile file, file.transferTo(new File(path));*/