我在使用SmartUpload上传的时候,是在action里面使用的。代码如下:
int count = 0;
SmartUpload mySmartUpload = new SmartUpload();
try {
mySmartUpload.initialize(config, request, response);
mySmartUpload.upload();
for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
com.jspsmart.upload.File myfile = mySmartUpload.getFiles().getFile(i);
String fileName = myfile.getFileName();
count = mySmartUpload.save("/upload");
//count = mySmartUpload.save(null);
}
out.println(count + " file uploaded.");
} catch (Exception e) {
out.println("Unable to upload the file.<br>");
out.println("Error : " + e.toString());
}问题:在执行到upload()方法时就卡在那了。
如果用jsp的话,是可以通过的,放在action里的话,就卡在那了,不知道是为什么,从网上查了下,也有人遇到过这个情况,但是没有找到解决方法 ,麻烦哪位大虾指点下。谢谢了!!!
int count = 0;
SmartUpload mySmartUpload = new SmartUpload();
try {
mySmartUpload.initialize(config, request, response);
mySmartUpload.upload();
for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) {
com.jspsmart.upload.File myfile = mySmartUpload.getFiles().getFile(i);
String fileName = myfile.getFileName();
count = mySmartUpload.save("/upload");
//count = mySmartUpload.save(null);
}
out.println(count + " file uploaded.");
} catch (Exception e) {
out.println("Unable to upload the file.<br>");
out.println("Error : " + e.toString());
}问题:在执行到upload()方法时就卡在那了。
如果用jsp的话,是可以通过的,放在action里的话,就卡在那了,不知道是为什么,从网上查了下,也有人遇到过这个情况,但是没有找到解决方法 ,麻烦哪位大虾指点下。谢谢了!!!
String suc =null;
ServletConfig config = getServlet().getServletConfig();
try {
mySmartUpload.initialize(getServlet().getServletConfig(),request, response); mySmartUpload.upload();
} catch (ServletException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
} catch (SmartUploadException e1) {
e1.printStackTrace();
}
我就是这样用的,不过就是在执行到upload方法的时候,就卡在那不动了,CPU也到100%,不知道是怎么回事呢???
去看看
一定不行,就放在JSP中了啊!