使用jspsmartupload来实现下载文件功能遇到的小问题
偶是菜鸟,最近在用jspsmartupload来实现文件下载时遇到了如下问题:messagedescriptionTheserverencounteredanintern...
偶是菜鸟,最近在用jspsmartupload来实现文件下载时遇到了如下问题:
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.IllegalArgumentException: File 'null' not found (1040).
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:532)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.IllegalArgumentException: File 'null' not found (1040).
com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:268)
com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:261)
com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:249)
org.apache.jsp.do_005fdownload_005f1_jsp._jspService(do_005fdownload_005f1_jsp.java:71)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
我的html页面表单如下:
<form action="./do_download_1.jsp" method="post"
enctype="multipart/form-data">
<table width="75%" border="1" align="center">
<tr>
<td>
<div align="center">
<input type="file" name="path" size="30">
</div>
</td>
</tr>
<tr>
<td>
<div align="center">
<input type="submit" name="Submit" value="下载它!">
</div>
</td>
</tr>
</table>
</form>
处理页面JSP do_download_1.jsp 如下:
<%@ page contentType="text/html;charset=gb2312"
import="com.jspsmart.upload.*"%>
<%
String source = request.getParameter("path");
//source = new String(source.getBytes("iso8859-1"), "gb2312");
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.setContentDisposition(null);
su.downloadFile(source);
out.clear();
out = pageContext.pushBody();
%>
我怀疑是字符格式的问题,可是一直没找到解决方法= =,请高手们指点下,不胜感激
to churongbo:
su.setContentDisposition(null);这里设置为NULL是为了不让浏览器直接打开文件。
问题已经解决:将<form action="./do_download_1.jsp" method="post" enctype="multipart/form-data"> 中的enctype="multipart/form-data"删掉就好了。还是自己学艺不精,没搞懂="multipart/form-data"的意思就乱加,呵呵 展开
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.IllegalArgumentException: File 'null' not found (1040).
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:532)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.IllegalArgumentException: File 'null' not found (1040).
com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:268)
com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:261)
com.jspsmart.upload.SmartUpload.downloadFile(SmartUpload.java:249)
org.apache.jsp.do_005fdownload_005f1_jsp._jspService(do_005fdownload_005f1_jsp.java:71)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
我的html页面表单如下:
<form action="./do_download_1.jsp" method="post"
enctype="multipart/form-data">
<table width="75%" border="1" align="center">
<tr>
<td>
<div align="center">
<input type="file" name="path" size="30">
</div>
</td>
</tr>
<tr>
<td>
<div align="center">
<input type="submit" name="Submit" value="下载它!">
</div>
</td>
</tr>
</table>
</form>
处理页面JSP do_download_1.jsp 如下:
<%@ page contentType="text/html;charset=gb2312"
import="com.jspsmart.upload.*"%>
<%
String source = request.getParameter("path");
//source = new String(source.getBytes("iso8859-1"), "gb2312");
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.setContentDisposition(null);
su.downloadFile(source);
out.clear();
out = pageContext.pushBody();
%>
我怀疑是字符格式的问题,可是一直没找到解决方法= =,请高手们指点下,不胜感激
to churongbo:
su.setContentDisposition(null);这里设置为NULL是为了不让浏览器直接打开文件。
问题已经解决:将<form action="./do_download_1.jsp" method="post" enctype="multipart/form-data"> 中的enctype="multipart/form-data"删掉就好了。还是自己学艺不精,没搞懂="multipart/form-data"的意思就乱加,呵呵 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询