解决方案 »

  1.   

    <param name="inputName">inputStream</param>  
      

  2.   

    我后台的方法getDownloadFile() 
      

  3.   

    框架返回的 是个 inputStream 流 ,你返回getDownloadFile 是个流吗?
      

  4.   

    public InputStream getDownloadFile() throws FileNotFoundException, UnsupportedEncodingException{
           fileN=new String(fileName.getBytes( "ISO8859-1" ), "utf-8" );
           File file = new File("D:\\xmxmmyeclipe6.5\\Gjdw_admin\\WebRoot\\"+DOWNLOADFILEPATH+fileN);
               System.out.println("dddddddddddddddddddddd"+DOWNLOADFILEPATH+fileN);
               InputStream is = new FileInputStream(file);              
                                                InputStream is = new FileInputStream(file);
                   return is;
              }     返回的是流
      

  5.   

    <param name="inputName">downloadFile</param>   public InputStream getDownloadFile() throws Exception  
        {  
           
               return ServletActionContext.getServletContext().getResourceAsStream(xxxx.jpg") ;  
             
        }  
      

  6.   

    //      public InputStream getDownloadFile() throws UnsupportedEncodingException {
    //      fileN=new String(fileName.getBytes( "ISO8859-1" ), "utf-8" );
    //     System.out.print( ServletActionContext.getServletContext().getResourceAsStream(DOWNLOADFILEPATH+fileN)+"/////////////大家后才是真的");
    //          return   
    //  ServletActionContext.getServletContext().getResourceAsStream(DOWNLOADFILEPATH+fileN);  
    //      }我一开始写过  没用  的    这样也不行   
      

  7.   

    报的错就是  Can not find a java.io.InputStream with the name [downloadFile] 没有流信息,你debug 测试,看看是否跑到你返回流的那句代码。
      

  8.   

     <action name="download" class="com.tzht.uploadmesAction.DownloadAction">  
                <!-- 设置文件名参数,由页面上传入 -->  
                <param name="fileName"></param>
      
                <result name="success" type="stream">  这个是不是 写在  result 中?
      

  9.   

      <result name="success" type="stream">  
                     <!-- 下载文件类型定义 -->  
                     <param name="contentType">  
                         application/octet-stream
                     </param>  
                     <!-- 下载文件处理方法 -->  
                     <param name="contentDisposition">  
                         attachment;filename="${downloadChineseFileName}"  
                     </param>  
                     <!-- 下载文件输出流定义 -->  
                     <param name="inputName">downloadFile</param>  
                      <param name="bufferSize">4096</param>  
                       <param name="contentLentgth">4096</param>
                 </result>  他们已经在一个大result中了呀
      

  10.   

     /**
         * @see org.apache.struts2.dispatcher.StrutsResultSupport#doExecute(java.lang.String, com.opensymphony.xwork2.ActionInvocation)
         */
        protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {        // Override any parameters using values on the stack
            resolveParamsFromStack(invocation.getStack(), invocation);        OutputStream oOutput = null;        try {
                if (inputStream == null) {
                    // Find the inputstream from the invocation variable stack
                    inputStream = (InputStream) invocation.getStack().findValue(conditionalParse(inputName, invocation));
                }       if (inputStream == null) {
                    String msg = ("Can not find a java.io.InputStream with the name [" + inputName + "] in the invocation stack. " +
                        "Check the <param name=\"inputName\"> tag specified for this action.");
                    LOG.error(msg);
                    throw new IllegalArgumentException(msg);
                }            // Find the Response in context
                HttpServletResponse oResponse = (HttpServletResponse) invocation.getInvocationContext().get(HTTP_RESPONSE);            // Set the content type
                if (contentCharSet != null && ! contentCharSet.equals("")) {
                    oResponse.setContentType(conditionalParse(contentType, invocation)+";charset="+contentCharSet);
                }
                else {
                    oResponse.setContentType(conditionalParse(contentType, invocation));
                }            // Set the content length
                if (contentLength != null) {
                    String _contentLength = conditionalParse(contentLength, invocation);
                    int _contentLengthAsInt = -1;
                    try {
                        _contentLengthAsInt = Integer.parseInt(_contentLength);
                        if (_contentLengthAsInt >= 0) {
                            oResponse.setContentLength(_contentLengthAsInt);
                        }
                    }
                    catch(NumberFormatException e) {
                        LOG.warn("failed to recongnize "+_contentLength+" as a number, contentLength header will not be set", e);
                    }
                }            // Set the content-disposition
                if (contentDisposition != null) {
                    oResponse.addHeader("Content-Disposition", conditionalParse(contentDisposition, invocation));
                }            // Set the cache control headers if neccessary
                if (!allowCaching) {
                    oResponse.addHeader("Pragma", "no-cache");
                    oResponse.addHeader("Cache-Control", "no-cache");
                }            // Get the outputstream
                oOutput = oResponse.getOutputStream();            if (LOG.isDebugEnabled()) {
                    LOG.debug("Streaming result [" + inputName + "] type=[" + contentType + "] length=[" + contentLength +
                        "] content-disposition=[" + contentDisposition + "] charset=[" + contentCharSet + "]");
                }            // Copy input to output
                LOG.debug("Streaming to output buffer +++ START +++");
                byte[] oBuff = new byte[bufferSize];
                int iSize;
                while (-1 != (iSize = inputStream.read(oBuff))) {
                    oOutput.write(oBuff, 0, iSize);
                }
                LOG.debug("Streaming to output buffer +++ END +++");            // Flush
                oOutput.flush();
            }
            finally {
                if (inputStream != null) inputStream.close();
                if (oOutput != null) oOutput.close();
            }
        }
      

  11.   

    奥  我明白了  但是我debug确实有对象呀java.io.FileInputStream@1ddc3ea没法传图   请问有何见解呀
      

  12.   

    连接1 
    连接2
    现在就是你的流没返回,contentLength  这个是返回的需要配吗 。
      

  13.   

    本来我没配   在网上查的加上了  不好试 没去   还有好像txt的文件可以下载  word,exel好行就不能  真怪
      

  14.   

           就报这个   别的没有了  严重 Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack. Check the <param name="inputName"> tag specified for this action.