Ich versuche, eine PowerPoint-Datei asynchron zum Client von einer Spring MVC @RequestMapping-Methode mit Apache POIs HSFL zurückzugeben. Ich kann jedoch nicht auf die Datei erhaltenPPT-Datei mit Spring MVC und Apache POI herunterladen
Hier ist mein Code
@RequestMapping(value = "/downloadPPT", produces = "application/vnd.ms-powerpoint")
public @ResponseBody byte[] downloadPPT(HttpServletResponse response) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] bytes = null;
HSLFSlideShow ppt = new HSLFSlideShow();
// add first slide
HSLFSlide s1 = ppt.createSlide();
// add second slide
HSLFSlide s2 = ppt.createSlide();
// save changes in a file
FileOutputStream out = new FileOutputStream("slideshow.ppt");
ppt.write(outputStream);
out.close();
bytes = outputStream.toByteArray();
return bytes;
}
Meine Antwort scheint zu sein, ein Byte-Version der ppt-Datei I erstellt, zum Download jedoch der Benutzer nicht aufgefordert, sich zum Downloaden die Datei. Was mache ich hier falsch?
http://stackoverflow.com/questions/5673260/downloading-a-file-from-spring-controllers –