一个关于jspsmartupload下载的问题,真的很急。有经验的好心人帮帮我吧!!!在线等...
昨天作了一个简单的下载的页面,可是总是有问题,在网上找了很多解决方法但是仍然不行!希望那位高手帮忙看下改下,感激之至!
HTML代码:
<html>
<head>
<title>下载</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
</head>
<body>
<a href="do_download.jsp">点击下载</a>
</body>
</html>
jsp代码:
<%@ page contentType="text/html;charset=gb2312" language="java" import="com.jspsmart.upload.*"%><%
// 新建一个SmartUpload对象
SmartUpload su = new SmartUpload();
// 初始化
su.initialize(pageContext);
// 设定contentDisposition为null以禁止浏览器自动打开文件,
//保证点击链接后是下载文件。若不设定,则下载的文件扩展名为
//doc时,浏览器将自动用word打开它。扩展名为pdf时,
//浏览器将用acrobat打开。
su.setContentDisposition(null);
// 下载文件
su.downloadFile("ITService\\uploadfiles\\002.xml");
%>
出现的错误:
java.lang.IllegalStateException: getOutputStream() has already been called for this response org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:611)
org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:190)
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.do_005fdownload_jsp._jspService(do_005fdownload_jsp.java:64)
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)
------解决方案--------------------
帮顶