Note: The latest version 1.1 view http://sunspot.blog.51cto.com/372554/681472, fixed Badversionclass
For a specific introduction to the STRUTS2 download component I am here to skip, look at this article is most of the comrades are encountered so people are very unhappy with the problem.
The final solution to the problem is described below.
Summary of questions:
In struts2 use result in type= "stream" results type, you can implement file download management, use is relatively smooth, but when in the "Download Prompt window" Click "Cancel button", always quote " Java.lang.IllegalStateException "Exception, the exception contents are as follows:
2011-1-8 20:34:20 org.apache.catalina.core.StandardWrapperValve Invoke severity: Servlet.service () for Servlet default threw Exception java.lang.IllegalStateException at Org.apache.catalina.connector.ResponseFacade.sendError (Responsefacad e.java:407) at Javax.servlet.http.HttpServletResponseWrapper.sendError (httpservletresponsewrapper.java:108) at Com.opensymphony.module.sitemesh.filter.PageResponseWrapper.sendError (pageresponsewrapper.java:176) at Javax.servlet.http.HttpServletResponseWrapper.sendError (httpservletresponsewrapper.java:108) at Org.apache.struts2.dispatcher.Dispatcher.sendError (dispatcher.java:770) at Org.apache.struts2.dispatcher.Dispatcher.serviceAction (dispatcher.java:505) at Org.apache.struts2.dispatcher.FilterDispatcher.doFilter (filterdispatcher.java:395) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:235) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (Applicationfilterchain.java:206) at Com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent ( sitemeshfilter.java:129) at Com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter (sitemeshfilter.java:77) A T 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.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.cor E.standardenginevalve.invoke (standardenginevalve.java:109) at Org.apache.catalina.connector.CoyoteAdapter.service (coyoteadapter.java:298) at Org.apache.coyote.http11.Http11Processor.process (http11processor.java:852) 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:662)
Network Solutions:
(Although this approach is feasible, I do not advocate it.) The concrete reasons explain afterwards. )
Most of the query solutions in the network are using exception handling, and the contents are as follows:
<package name= "Default" extends= "Struts-default" >
<global-results>
<result name= " Client-abort-exception ">/ignored.jsp</result>
</global-results>
</package>
<package name= "main" extends= "Struts-default" >
<exception-mapping result= "Client-abort-exception" exception= "Org.apache.catalina.connector.ClientAbortException"/>
<action name= "Download" com. Downloadaction ">
<result name=" Success "type=" Stream ">
<param name=" InputName ">targetfile </param>
<param name= "contentdisposition" >filename= "</param>
<param name=" BufferSize ">4096</param>
</result>
</action>
</package>
In other words, if you throw a clientabortexception exception, jump to the "ignored.jsp" page, which is not on the page.
Another option is to do a try on the page. Catch, then do nothing