I am writing application using AngularJS and Spring. I would like to send request to the server and download response returned from controller as a file. In controller I hav
//JAVA PART
@RequestMapping(value = "/report-excel", method = RequestMethod.GET)
public ResponseEntity getReportExcel(@RequestParam("bookingStatusType") String bookingStatusType,
@RequestParam("endDate") String endDate, @RequestParam("product") String product, @RequestParam("startDate") String startDate)throws IOException, ParseException {
//Generate Excel from DTO using any logic after that do the following
byte[] body = wb.getBytes();
HttpHeaders header = new HttpHeaders();
header.setContentType(new MediaType("application", "xlsx"));
header.set("Content-Disposition", "inline; filename=" + fileName);
header.setCacheControl("must-revalidate, post-check=0, pre-check=0");
header.setContentLength(body.length);
return new ResponseEntity(body, header, HttpStatus.OK);
}
//HTML PART
Test