<action name="downloadAction" class="">
<result type="stream">
<param name="contentDispositon">attachment;filename=${filename}</param><!--attachment表示不打开下载,设置文件的名字-->
<param name="inputName">downloadFile</param><!-- 设置读取的方法(在action中的方法对应的getDownloadFile(){}) -->
</result>
</action>
1 public InputStream getDownloadFile(){ 2 try{ 3 if(1==number){ 4 this.filename=new String(this.filename.getBytes("gbk"),"8859_1"); 5 return ServletActionContext.getServletContext().getResourceAsStream("/upload/java.txt"); 6 }else{ 7 return ServletActionContext.getServletContext().getResourceAsStream("/upload/...."); 8 } 9 }catch(Exception ex){ 10 ex.printStackTrace(); 11 } 12 13 return null; 14 }