我在使用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里的话,就卡在那了,不知道是为什么,从网上查了下,也有人遇到过这个情况,但是没有找到解决方法 ,麻烦哪位大虾指点下。谢谢了!!!

解决方案 »

  1.   

    这都是没有问题的,放在jsp里可以,放到action里就不行了,不知道为什么,难道在action里不能用?
      

  2.   

    action中:SmartUpload mySmartUpload = new SmartUpload(); 
    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(); 

      

  3.   


    我就是这样用的,不过就是在执行到upload方法的时候,就卡在那不动了,CPU也到100%,不知道是怎么回事呢???
      

  4.   

    http://leesonhomme.javaeye.com/blog/491105
    去看看
      

  5.   

    我用的是smartupload,想解决上面的问题呀!!!
      

  6.   

    你的config是怎么来的?
    一定不行,就放在JSP中了啊!
      

  7.   

    getServlet().getServletConfig(); 就是这种方式获取的呀