问题描述
按照网上的方法写好了ACTION 方法和配置文件.但是点下载的时候不能弹出保存对话框,后台也不报错.是怎么回事啊.<actionname="download"class="downloadAction"method="getexecute"><resultname="success"type="stream"><paramname="inputPath">/upload/</param><paramname="contentType">application/octet-stream;charset=ISO8859-1</param><paramname="inputName">inputStream</param><paramname="contentDisposition">attachment;filename="${downFileName}"</param><paramname="bufferSize">4096</param></result></action>DownloadAction privateStringfileName;privateStringinputPath;privateInputStreaminputStream;privateStringdownFileName;publicStringgetFileName(){returnfileName;}publicStringgetInputPath(){returninputPath;}publicvoidsetInputStream(InputStreaminputStream){this.inputStream=inputStream;}publicInputStreamgetInputStream(){returninputStream;}publicStringgetDownFileName(){returndownFileName;}publicvoidsetDownFileName(StringdownFileName){this.downFileName=downFileName;}publicStringgetexecute()throwsException{Chanceattachanceatta=chanceattaService.getChanceatta(chanceattid);intattachmentid=chanceatta.getAttachment().getAttachmentid();Attachmentattach=attachmentService.getAttachment(attachmentid);fileName=attach.getFilename();Stringurl="/upload/"+attach.getFilename();intsize=url.length()-1;for(inti=0;i<size;i++)url=url.replace("\","/");System.out.println(ServletActionContext.getServletContext().getResourceAsStream(url));inputStream=ServletActionContext.getServletContext().getResourceAsStream(url);this.setInputStream(inputStream);downFileName=fileName;downFileName=newString(downFileName.getBytes(),"ISO8859-1");this.setDownFileName(downFileName);System.out.println("///");returnSUCCESS;}publicvoidsetInputPath(StringinputPath){this.inputPath=inputPath;}publicvoidsetFileName(StringfileName){this.fileName=fileName;}