mySmartUpload.downloadFile(path+filename,"APPLICATION/OCTET-STREAM",downloadname);你换换"APPLICATION/OCTET-STREAM"的方式看看

解决方案 »

  1.   

    <%@ page language="java"  contentType="text/html" import="com.jspsmart.upload.*,java.net.*"%>
    <jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
    <%

    String filepath=URLDecoder.decode(request.getParameter("f_path"));
    String strName = URLDecoder.decode(request.getParameter("strName"));
    String strShowName = URLDecoder.decode(request.getParameter("strShowName"));

    try{// Initialization
    mySmartUpload.initialize(pageContext);
    // With options
    mySmartUpload.setContentDisposition("attachment;");
    mySmartUpload.downloadFile(filepath+strName,null,strShowName);
    }catch(Exception e){
    out.print("文件下载错误,该文件可能不存在!<br>");
    out.print("<a href='javascript:history.back();'>返回</a>");
    System.err.println("文件下载错误"+e.getMessage());
    }
    %>
      

  2.   

    楼上两位的方法我都实验了,结果一样:文件中有内容就失败,无内容就成功;
    发生的异常:
      org.apache.jasper.JasperException: getOutputStream() has already been called for this response
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    //////////////////////////////////////java.lang.IllegalStateException: getOutputStream() has already been called for this response
    at org.apache.coyote.tomcat4.CoyoteResponse.getWriter(CoyoteResponse.java:614)
    at org.apache.coyote.tomcat4.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:173)
    at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:173)
    和我的TOMCAT的版本有关系吗?
    谢谢了,着急!!
      

  3.   

    和TOMCAT没关系,但是你的smart.jar应该加了吧~要不也不会下载空文件成功~
    觉得还是你的初始化有问题,下面试我的参考下
    private void init(PageContext pageContext){
            try{
                upload = new SmartUpload();
                upload.initialize(pageContext);
                upload.upload();
                request = upload.getRequest();
            }catch(Exception e){
                System.err.println("UploadBean Error:"+e);
            }
        }
    要是包下的不全这可能很小吧~
      

  4.   

    TO realby(忽然睡了):
      你说的smart.jar : 我下载的文件里面没有啊.
      是什么东西啊?
      难道我下载的不全?我下载的压缩文见大小是不是113K,对不对啊?
      

  5.   

    问题解决.晕了,问题是JSP文件中在<%@ page contentType="text/html; charset=shift_jis" %><%@ page language="java" import="com.jspsmart.upload.*"%><jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /><% ........  %>外不允许有任何字符.
      

  6.   

    还有一个问题,解决了马上放分.
    DOWNLOAD文件完成之后,不能切换到其他页面,IE下边的状态栏提示显示页面完成,但是页面并不切换,必须按"刷新"之后才恢复正常.为什么?是要做什么释放操作吗?
      

  7.   

    可能是size不对吧,我记得上传的时候有个size要设定的,下载也许也有关系的吧
      

  8.   

    现在的情况是这样:
       我的页面是一个框架,左边是菜单,右边是下载的窗口.
       现在左边的菜单是用<a></a>做的,右边下载完之后点左边的菜单没反映.
       把<a></a>换成button就好用,为什么?
    是<a></a>的target的原因,如果不用target,新打开窗口,就可以.
       如何解决啊?