错误信息:java.lang.IllegalStateException: getOutputStream() has already been called for this response
org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:614)
org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:210)
org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:167)
org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:160)
org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:235)
org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:160)
org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:120)
org.apache.jsp.jsp.soft.util_jsp._jspService(util_jsp.java:63)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
com.goldcool.comim.filter.EncodingConvert.doFilter(EncodingConvert.java:22)

解决方案 »

  1.   

    以上原因一个都不存在,自己测试时有的可以,有的不行。
    数据库用的big5,页面用gb2312会不会出现问题。
      

  2.   

    Action 代码如下:import org.apache.struts.action.*;
    import javax.servlet.http.*;public class Download extends Action {
      public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        /**@todo: complete the business logic here, this is just a skeleton.*/
        try {
          String id = httpServletRequest.getParameter("id");
          String name = httpServletRequest.getParameter("name");
          String dir = httpServletRequest.getParameter("dir");      if (id == null || name == null || dir == null) {
            return new ActionForward(actionMapping.getInput());
          }
          String path = "/WEB-INF/download/" + dir + "/" + name;
          httpServletRequest.setAttribute("path",path);
        }catch(Exception e) {
          System.out.println(e.getMessage());
          return new ActionForward(actionMapping.getInput());
        }    return actionMapping.findForward("success");
      }
    }下载页代码:
     
    <%@ page contentType="text/html;charset=gb2312"
    import="com.jspsmart.upload.*,java.util.*,java.io.*" %><%
    String file = (java.lang.String)request.getAttribute("path");
    SmartUpload su = new SmartUpload();
    su.initialize(pageContext);
    su.setContentDisposition(null); su.downloadFile(file);
    %>
      

  3.   

    恩,和我的问题一样,前2天我也问过,没人帮我解答,关注
    而且我不用jspsmartupload直接在页面写下载的代码也出同样错,
    具我观察,是在关闭getOutputStream流的时候出错,
    我也断点看过,前边读取都没有任何错误,就在关闭的时候就报错
      

  4.   

    下载页代码改成<%@ page contentType="text/html;charset=gb2312" 
    import="com.jspsmart.upload.*,java.util.*,java.io.*"%><%
    String file = (java.lang.String)request.getAttribute("path");
    SmartUpload su = new SmartUpload();
    su.initialize(this.getServletConfig(),request,response);//《--
    su.setContentDisposition(null); su.downloadFile(file);
    %>