这是我在Action 中编的代码,运行之后CPU占有率100%,浏览器的进度条走了一半就停了,网上找了很久,一大堆人遇到这种情况,就是没人给出真正的解决方法,不知哪位高手可以帮忙? String path = "";
SmartUpload su = new SmartUpload();
su.initialize(this.getServlet().getServletConfig(),req,res);
su.upload();
String destination = "/kpx/homeworks";
for(int i = 0;i < su.getFiles().getCount();i++){
com.jspsmart.upload.File file = su.getFiles().getFile(i);
if(!file.isMissing()){
path = destination+file.getFileName();
file.saveAs(path);
}
}
SmartUpload su = new SmartUpload();
su.initialize(this.getServlet().getServletConfig(),req,res);
su.upload();
String destination = "/kpx/homeworks";
for(int i = 0;i < su.getFiles().getCount();i++){
com.jspsmart.upload.File file = su.getFiles().getFile(i);
if(!file.isMissing()){
path = destination+file.getFileName();
file.saveAs(path);
}
}
<form action="homeworkAction.do" method="post" enctype="multipart/form-data">
<table align="center">
<tr>
<td colspan=3 class=TableTitle1>
作业发布:
</td>
</tr>
<tr>
<td>
标题:
</td>
<td>
<INPUT TYPE="text" NAME="title" SIZE="40">
</td>
<td></td>
</tr>
<tr>
<td>
作业文件:
</td>
<td>
<input type = "file" name = "file" size="30">
</td>
</tr>
<tr>
<td>作业提交截止时间:</td>
<td>
<input type ="text" name = "endDate" size="40">
</td>
</tr>
<tr>
<td><input type="hidden" name="methodvalue="uploadHomework">
input type="hidden" name="type" value="1">
</td>
<td>
<INPUT type=submit value=提交 name=ok>
</td>
</table>
</form>
2 可以在你的代码里面嵌入 logger 语句,或者干脆 System.out.println()语句,看看程序运行到哪里卡住了
这是调试方法。OVER
1.按照你第一个方法做,结果还是一样
2.经过高度发现程序卡在 su.upload(); 这个地方
注:类似的代码,如果我放在Jsp页面上是可以正常上传的,但我要的是在Action里能正常上传,