我用weblogic8.0
非常好用。

解决方案 »

  1.   

    用google搜一下,一定能搜出不少
      

  2.   

    <jsp:usebean id="su1" scope="page" class="com.jspsmart.upload.SmartUpload" >
    <%
    su1.initialize(pageContext);
    su1.setAllowedFilesList("txt","rar","exe","doc","zip");
    su1.upload();
    try{
       su1.saveAs("D:\\temp\\");
    }catch(Exception e){}
    %>用jsp标签试试
      

  3.   

    用SmartUpload这个组件,感觉还比较好用
      

  4.   

    上传用用SmartUpload这个组件
    下载:
    <%! public static String toUtf8String(String s) {
            StringBuffer sb = new StringBuffer();
            for (int i=0;i<s.length();i++) {
                char c = s.charAt(i);
                if (c >= 0 && c <= 255) {
                    sb.append(c);
                } else {
                    byte[] b;
                    try {
                        b = Character.toString(c).getBytes("utf-8");
                    } catch (Exception ex) {
                        System.out.println(ex);
                        b = new byte[0];
                    }
                    for (int j = 0; j < b.length; j++) {
                        int k = b[j];
                        if (k < 0) k += 256;
                        sb.append("%" + Integer.toHexString(k).
                        toUpperCase());
                    }
                }
            }
            return sb.toString();
        }
    %>
    <%
    String filename=toUtf8String(request.getParameter("file"));
    System.out.println("filename = "+filename);
    String  ext= "";
    String fileurl = "";
    if(!filename.equals("")){
    int i = filename.lastIndexOf(".");
    ext = filename.substring(i + 1);
    int j = filename.lastIndexOf("/");
    fileurl = filename.substring(j + 1);
    }
    /*if(!ext.equals("rar") && !ext.equals("zip")){
    try{
    fileurl=getServletContext().getRealPath("" + filename);
    System.out.println("文件路径 = "+fileurl);
    // Initialization
    mySmartUpload.initialize(pageContext);
    //Download field
    mySmartUpload.downloadFile(fileurl);
    }catch(Exception ee){
    System.out.println(ee);
    }
    }else{*/
    response.setContentType("bin");
         response.setHeader("Content-disposition","attachment; filename="+fileurl);
    BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        try {
             bis = new BufferedInputStream(new FileInputStream(getServletContext().getRealPath("" + filename)));
             bos = new BufferedOutputStream(response.getOutputStream());

             byte[] buff = new byte[2048];
             int bytesRead;

             while(-1 != (bytesRead = bis.read(buff, 0, buff.length))){
                 bos.write(buff,0,bytesRead);
             }

         } catch(final IOException e) {
             System.out.println ( "出现IOException." + e );
         } finally {
             if (bis != null)
                 bis.close();
             if (bos != null)
                 bos.close();
         }
    //}
    %>
      

  5.   

    上 www.apache.org 下一个 比 SmartUpload 好