import org.apache.tomcat.util.http.fileupload.IOUtils;
@GetMapping("previewPDF")
public void previewPDF(HttpServletResponse response){
log.info("双非pdf预览 | UnlistedPageDataController.previewPDF | 任务开始,");
ClassPathResource resource = new ClassPathResource("file/国民经济行业分类.pdf");
InputStream input = null;
try {
input = resource.getInputStream();
response.setContentType("application/octet-stream");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode("国民经济行业分类", "utf-8"));
IOUtils.copy(input, response.getOutputStream());
log.info("双非pdf预览 | UnlistedPageDataController.previewPDF | 任务结束,");
} catch (Exception e) {
log.error("UnlistedPageDataController previewPDF fail.",e);
} finally {
if (input != null) {
IOUtils.closeQuietly(input);
}
}
}
java pdf预览
最新推荐文章于 2024-06-28 09:57:46 发布