我的项目目录中有一个pdf文件,我必须获取该pdf文件并将其作为响应发送并在前端(UI)中显示
所以我尝试了以下代码:
@GetMapping(value = "/getDocument/{id}")
public HttpServletResponse
getDocumentByAssocLeadDocId(@PathVariable("id") int id
,HttpServletRequest request,HttpServletResponse
response) {
List<LeadDetailsDTO> leadList = null;
ResponseEntity<Map<String, Object>> responseEntity = null;
try {
String path = leadService.getDocumentByAssocLeadDocId(id);
File file=new File(path);
PDDocument pdf = PDDocument.load(file);
ServletOutputStream outStream = response.getOutputStream();
//outStream.write(b);
}
catch (Exception e) {
e.printStackTrace();
}
return response;
}
我如何发送带有响应的信息,并且单击查看按钮时想在新标签中显示pdf?
如果至少没有下载,请帮助我。谢谢。