您好,欢迎光临本网站![请登录][注册会员]  
文件名称: 下载点取消报异常最终解决办法
  所属分类: Java
  开发工具:
  文件大小: 5kb
  下载次数: 0
  上传时间: 2014-03-27
  提 供 者: u0139*****
 详细说明: Struts2 下载点取消报异常最终解决办法 在我们做struts2文件下载的时候,经常会遇到这种问题:点“打开/保存”一切正常,但当我们点击“取消”时,却报一堆的异常,非常让人头疼,错误如下(每个人的错误估计不太一样,以我的为例): 2011-5-19 10:30:23 org.apache.catalina.core.ApplicationDispatcher invoke 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response at org.apache.catalina.connector.Response.getWriter(Response.java:611) at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198) at javax.servlet.ServletResponseWrapper .getWriter(ServletResponseWrapper.java:112) at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:112) at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:125) at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:118) at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:180) at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:118) at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:77) at org.apache.jsp.layout.adminlayout_jsp._jspService(adminlayout_jsp.java:204) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:39) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551) at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488) at com.opensymphony.module.sitemesh.filter.PageFilter.writeDecorator(PageFilter.java:173) at com.opensymphony.module.sitemesh.filter.PageFilter.applyDecorator(PageFilter.java:158) at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:62) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:164) at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:141) at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:90) at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:417) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619) 异常原因分析: [stream对应的类是org.apache.struts2.dispatcher.StreamResult,该类的处理过程如下: 1.配置其中result标签下的各个参数 2.从服务器中获取输入流,并同时与客户端建立输出流(服务器与客户端链接通过Socket进行连接) 3.当点击“保存”或“打开”时,开始传输数据。如果点击“取消”,关闭所有的流。 这里要注意的是,但是实际发现Socket并没有断开!并且流也没有关闭!这一点非常重要! 所以在JSP容器通过Response获取输出流之前,前面的流并没有关闭,所以会造成该异常的报出。 我在CSDN上搜了一个人的解决方法,他是这么解决的: /null.jsp /upload/download targetFile attachment;filename="${downloadFileName}" 4096 也就是说,如果抛出了ClientAbortException异常,那就跳转到“null.jsp”这个页面,这个页面中什么内容都没有。虽然这种方法暂时可行,但是当遇到其他异常的时候,也就是非ClientAbortException之后,这个方法就不可行了。我之前也是参照这种方法配置,但昨天我重新启动应用的时候,点击“取消”居然还报错,错误就是上面的一堆“java.lang.IllegalStateException”,而且这种方法也是一种逃避的方法,也就是置之不理。这并不可取,解决问题就要解决彻底明了,逃避是没用的,经过网上大师们的分析测试,最终解决办法如下: 1.下载一个插件struts2-sunspoter-stream-1.0.jar(附件中有下载)。 2.将附件解压获取struts2-sunspoter-stream-1.0.jar,并复制在/WEB-INF/lib下。 3.在原有的struts.xml的基础上进行相应的配置,配置如下: /upload/download targetFile attachment;filename="${downloadFileName}" 4096 在这种方式下,只需添加一个result-type,将原有的result中type改为“streamx”,其他一律不变,在这种情况下,点击“取消”的同时也关闭了流,不会再报出该异常。 ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: struts2
 输入关键字,在本站1000多万海量源码库中尽情搜索: