当前位置: 代码迷 >> Java Web开发 >> Struts2 文件下载Action报重复提交异常
  详细解决方案

Struts2 文件下载Action报重复提交异常

热度:20   发布时间:2016-04-16 22:05:15.0
求助:Struts2 文件下载Action报重复提交错误
本帖最后由 SiuLo 于 2014-07-31 14:21:52 编辑
控制台错误:
Cannot call sendError() after the response has been committed

Action:
public InputStream getInputStream() throws Exception {  
          // getInputPath() 获取依赖注入,是文件夹名称
          // getFileName()是前台传过来需要下载的文件名
InputStream in=ServletActionContext.getServletContext().getResourceAsStream(getInputPath() + "\\" + getFileName());
        return in; 

    }  
  
    @Override  
    public String execute() throws Exception {  
        return SUCCESS;  
    }

配置:
<action name="download" class="我的路径.DownloadAction">
     <param name="inputPath">upload</param>
     <result name="success" type="stream">
     <param name="contentType">application/octet-stream;charset=ISO8859-1</param>
     <!-- 这里的赋值方式 与 fileUploadInterceptor的allowedTypes方式相同 -->
     <param name="contentDisposition">attachment;fileName="${fileName}"</param>
     <param name="inputName">inputStream</param>
     <param name="bufferSize">4096</param>
     </result>
     <result name="error">error.jsp</result>
    </action>


请教各位需要怎么改正?
------解决方案--------------------
? @Override??
????public?String?execute()?throws?Exception?{??
????????return?null;??
????}
  相关解决方案