网上找了好多资料,但还是报错java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.贴出代码如下,请高手指点...struts.xml
<action name="down" class="learn.action.downloadAction">
    <result name="success" type="stream"> 
<param name="contentType">application/vnd.ms-word</param> 
<param name="inputName">inputStream</param> 
<param name="contentDisposition">attachment;filename="${fileName}"</param> 
         <param name="bufferSize">40960</param> 
    </result> 
 </action>

DownloadActon类
public class DownloadAction extends ActionSupport{
private String fileName;
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileName(){
return fileName;
}
       public InputStream getInputStream() throws Exception {
            ServletContext sc = ServletActionContext.getServletContext();
            String realpath = sc.getRealPath("/upload");
            String path = realpath + "\\" + this.fileName;
            System.out.println("<<<" + this.fileName);
            System.out.println(">>>" + path);
            return ServletActionContext.getServletContext().getResourceAsStream(path);
         }
public String execute()throws Exception{
return SUCCESS;
}
}

解决方案 »

  1.   

    <param name="inputName">inputStream</param> 说这句有问题,InputStram  你把这个名字改改,试试.......
      

  2.   


    网上找了好多资料,但还是报错java.lang.IllegalArgumentException: Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the <param name="inputName"> tag specified for this action.
    没有找到java io InputStream
    <!--
          inputName默认值是InputStream,如果action中用于读取下载文件内容的属性名是inputStream,那麽可以省略这个参数;注意大小写
         -->
    <param name="inputName">inputStream</param>//inputStream属性的getter方法,StreamResult结果类型使用该属性来读取下载文件的内容
    public InputStream getInputStream() throws Exception{
    .....
      

  3.   

    下载问题解决了...不过这只是针对非中文名字的文件下载,并不是不能支持中文下载只是下载传递的中文参数变成了乱码,在调试过程中把乱码参数改为中文还是可以下载的,为什么传递的参数是乱码呢??请高手指点,现把更改后的原代码贴出如下 :
    public class downloadAction extends ActionSupport{
    private String fileName;
    public void setFileName(String fileName){
    this.fileName =fileName;
    }
    public String getFileName(){
    return fileName;
    }
    public String getDownloadFileName() {    
            String downFileName = fileName;    
            try {    //转换为下载文件名也是支持中文的下载名
                downFileName = new String(downFileName.getBytes(), "ISO8859-1");    
            } catch (UnsupportedEncodingException e) {    
                e.printStackTrace();    
            }    
            return downFileName;    
        }    
     public InputStream getInputStream() throws Exception {    
     ServletContext sc = ServletActionContext.getServletContext();
         String realpath = sc.getRealPath("/WEB-INF/upload");
         String path = realpath + "\\" + this.fileName; 
     return new FileInputStream(path); 
        } 
     
    public String execute()throws Exception{
    return SUCCESS;
    }
    }XML配置文件
    <!-- 文件下载,支持中文附件名 -->
     <action name="down" class="learn.action.downloadAction">
        <result name="success" type="stream"> 
    <param name="contentType">application/octet-stream;charset=ISO8859-1</param> 
    <param name="inputName">inputStream</param> 
    <param name="contentDisposition">attachment;filename="${downloadFileName}"</param> 
    <param name="bufferSize">327680</param> 
         </result> 
     </action>
      

  4.   

    对了,我的JSP页面和数据库字符编码全部是设置为UTF-8,而且插入数据和读取数据、中文都没有问题。
      

  5.   

    在下载的时候,有get和post传参,所以有乱码
      

  6.   

    在Struts.xml配置文件配置如下常量:
    <constant name="struts.multipart.maxSize" value="1000000"/>你说的问题马上就解决了!!!!!!!!!!!!!!!!