@RequestMapping(value = "/downlaod/{fileName}", method = RequestMethod.GET)
public void getFile(
@PathVariable("fileName") String fileName,
HttpServletResponse response) {
try {
InputStream is = ...; // get uploaded file using InputStream
org.apache.commons.io.IOUtils.copy(is, response.getOutputStream()); // copy this to response's OutputStream
response.flushBuffer();
} catch (IOException ex) {
log.info("Error writing file to output stream. Filename was '{}'", fileName, ex);
throw new RuntimeException("IOError to writing file on output stream");
}
}
if you having response.getOutputStream(), you can write what you want into there. You have pass this output stream as a place to put generated PDF. you can also set
response.setContentType("application/pdf");