Adding an object to a ModelAndView in a Spring controller after forcing a download does not seem to work.
Code at Controller method
ModelAndView view = new ModelAndView("");
view.setViewName("pom-upload");
view.addObject("uploadStatus", "Uploaded pom has been successfully processed!");
response.setHeader("Content-Disposition", "attachment; filename=pom.xml");
IOUtils.copy(inputStreamToDownload, response.getOutputStream());
response.flushBuffer();
return view;
I get the file downloaded successfully.
But when I try to access the "uploadStatus
" message in my JSP like
<c:out value="${uploadStatus}"></c:out>
or
div id="status-message" class="alert alert-success" role="alert">${uploadStatus}</div>
I do not get the message from ${uploadStatus}
What could the reason be and how would I fix this?