日期:2014-05-17 浏览次数:20847 次
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" import="com.jspsmart.upload.*"%> <% // 新建一个SmartUpload对象 SmartUpload su = new SmartUpload(); // 初始化 su.initialize(pageContext); // 设定contentDisposition为null以禁止浏览器自动打开文件, //保证点击链接后是下载文件。若不设定,则下载的文件扩展名为 //doc时,浏览器将自动用word打开它。扩展名为pdf时, //浏览器将用acrobat打开。 su.setContentDisposition(null); // 下载文件 su.downloadFile("/document/"+(String)request.getAttribute("fileName")); out.clear(); out=pageContext.pushBody(); %> 这是我用的下载jsp,用的是SmartUpload这个包做下载,有一个情况会出现这个问题就是在点击下载时(如果装有迅雷或其它下载工具会自动启用)如果关闭下载工具想用浏览器下载就会报如下的错误,现在求一个解决方案,有什么好的下载方式可以避免这个问题的发生。 [ERROR]http-8081-10-org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[action]-Servlet.service() for servlet action threw exception java.io.IOException at org.apache.coyote.http11.InternalAprOutputBuffer.flushBuffer(InternalAprOutputBuffer.java:696) at org.apache.coyote.http11.InternalAprOutputBuffer$SocketOutputBuffer.doWrite(InternalAprOutputBuffer.java:726) at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:118) at org.apache.coyote.http11.InternalAprOutputBuffer.doWrite(InternalAprOutputBuffer.java:532) at org.apache.coyote.Response.doWrite(Response.java:560) at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:353) at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:352) at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:381) at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:370) at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89) [color=#FF6600]at com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:579) at com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:508) at com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:476)[/color] at org.apache.jsp.webs.report.load_jsp._jspService(load_jsp.java:67) 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.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063) at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414) at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.i