我正在尝试下载一个发布请求返回的PDF文件:
这是我的角度法:
sendPost: void {
const options = {headers: {'Content-Type': 'application/json'}};
this.http.post('http://localhost:8080/export', JSON.stringify(this.filter),
options )
.subscribe((next) => console.log(next));
}
以及生成PDF的Java后端:
@CrossOrigin
@RequestMapping(value = "/export/", method = RequestMethod.POST)
public ResponseEntity<byte[]> getFilteredPDF(@RequestBody PdfExportFilter filter) throws IOException, DocumentException {
StructureExporter writer = new FilteredPdfExporter(filter);
Path filePath = Paths.get(writer.getBaseTempDir() + "/filteredExport.pdf");
writer.exportData();
return new ResponseEntity<byte[]>(readPdfBytes(filePath), getHttpHeaders("_filtered_export"), HttpStatus.OK);
}
我怎样才能保存退货
byte[]
把它下载到客户机上?