做了一个JSP上传页面,但是有错误(用JSPSmartupload做的) 20

用JSPSmartupload包做了一个上传页面但是浏览器一直抱错。浏览器报错信息如下:typeExceptionreportmessagedescriptionThes... 用JSPSmartupload包做了一个上传页面但是浏览器一直抱错。

浏览器报错信息如下:
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Exception in JSP: /test.jsp:15

12:
13:
14: int fileCount=theSmartUpload.save(savePath) ;
15: theSmartUpload.upload() ;
16: out.println("成功上传文件数目:"+fileCount ) ;
17:
18: %>

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NegativeArraySizeException
com.jspsmart.upload.SmartUpload.upload(SmartUpload.java:218)
org.apache.jsp.test_jsp._jspService(test_jsp.java:66)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs

页面代码如下:
%@ page contentType="text/html; charset=GB2312" language="java" %>
<%@ page pageEncoding="GB2312" %>
<%@ page import="com.jspsmart.upload.*" %>
<jsp:useBean id="theSmartUpload" scope="request" class="com.jspsmart.upload.SmartUpload"/>
<%

theSmartUpload.initialize(pageContext) ;
theSmartUpload.setTotalMaxFileSize(5*1024*1024) ;

String savePath = "C:\\saveDir\\" ;

int fileCount=theSmartUpload.save(savePath) ;
theSmartUpload.upload() ;
out.println("成功上传文件数目:"+fileCount ) ;

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>测试上传</title>
</head>

<body>
<form action="test.jsp"
enctype="multipart/form-data"
name=theFile method="post" >
<input type=file name=File1 size=50 /> <br>
<input type=submit name=submitButton value="上传" />
</form>
</body>
</html>
展开
 我来答
百度网友433ca9194
2007-11-24 · TA获得超过624个赞
知道答主
回答量:98
采纳率:0%
帮助的人:95.2万
展开全部
int fileCount=theSmartUpload.save(savePath) ;
theSmartUpload.upload() ;
先调用upload()方法,在上传,即把这两句调换一下
theSmartUpload.upload() ;
int fileCount=theSmartUpload.save(savePath) ;
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式