不过下载的文件只要是中文文件名的在保存的时候就出现乱码,所以想要个支持中文文件名的jspsmartupload.jar,非常感谢。谁有请发收到后马上就会结贴

解决方案 »

  1.   

    to:yeah920,我下载的不支持啊,你那有支持的吗?
      

  2.   

    我发给你
    请查收
    [email protected]
      

  3.   

    to:ldzyz0007() 你的我收到了,可是还不行,还是乱码,你这个jsmartupload是没修改以前的,我要的是修改以后的啊
      

  4.   

    分真多呀   又一个
    对jspSmartUpload组件的SmartUpload类做了升级处理,增加了toUtf8String这个方法,改动部分源码如下:
    public void downloadFile(String s, String s1, String s2, int i)        throws ServletException, IOException, SmartUploadException    {        if(s == null)            throw new IllegalArgumentException("File '" + s +            "' not found (1040).");        if(s.equals(""))            throw new IllegalArgumentException("File '" + s +            "' not found (1040).");        if(!isVirtual(s) && m_denyPhysicalPath)            throw new SecurityException("Physical path is            denied (1035).");        if(isVirtual(s))            s = m_application.getRealPath(s);        java.io.File file = new java.io.File(s);        FileInputStream fileinputstream = new FileInputStream(file);        long l = file.length();        boolean flag = false;        int k = 0;        byte abyte0[] = new byte[i];        if(s1 == null)            m_response.setContentType("application/x-msdownload");        else        if(s1.length() == 0)            m_response.setContentType("application/x-msdownload");        else            m_response.setContentType(s1);        m_response.setContentLength((int)l);        m_contentDisposition = m_contentDisposition != null ?        m_contentDisposition : "attachment;";        if(s2 == null)            m_response.setHeader("Content-Disposition",             m_contentDisposition + " filename=" +             toUtf8String(getFileName(s)));        else        if(s2.length() == 0)            m_response.setHeader("Content-Disposition",             m_contentDisposition);        else            m_response.setHeader("Content-Disposition",             m_contentDisposition + " filename=" + toUtf8String(s2));        while((long)k < l)        {            int j = fileinputstream.read(abyte0, 0, i);            k += j;            m_response.getOutputStream().write(abyte0, 0, j);        }        fileinputstream.close();    }     /**     * 将文件名中的汉字转为UTF8编码的串,以便下载时能正确显示另存的文件名.     * 纵横软件制作中心雨亦奇2003.08.01     * @param s 原文件名     * @return 重新编码后的文件名     */    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();    }
      

  5.   

    其实下载的时候可以不用 jspsmartupload.接收到下载的请求后,执行一下下边的这段代码。也可以实现下载:
    String filePath = "/文件夹1/文件夹2/JAVA教程.doc";
    String fileName = "JAVA教程"; 
    String serverPath = request.getRealPath("");
    response.setContentType("APPLICATION/OCTET-STREAM"); 
    response.setHeader("Content-disposition","attachment;filename=" + new String(fileName.getBytes(),"iso8859-1"));java.io.FileInputStream fileInputStream = null;
    PrintWriter out = null;
    try { 
    fileInputStream = new java.io.FileInputStream(serverPath + filePath); 
    out = response.getWriter(); int i; 
    while ((i=fileInputStream.read()) != -1) { 
    out.write(i); 

    } catch(FileNotFoundException fe){
    fe.printStackTrace();
    System.out.println(errMsg= "file is not exist");
    }
    catch (Exception e) {
    e.printStackTrace();
    System.out.println(errMsg= "download failed");
    } finally{
    if(fileInputStream != null)
    fileInputStream.close(); 
    if(out != null)
    out.close(); 
    }
      

  6.   

    非常感谢大家帮助我,zzj9898给我发的jar正是我想要的支持中文文件名的,所以给予分最高、
     yinchongyi和ldzyz0007发的虽然不支持中文但是在QQ上帮我找了很多资料,非常感谢。
    haikeyiguo (10)提出了另一种思路,给10分,以示感谢。xizhiyao(流浪的猴子) ,在另一个帖子里给分了,在这里就不重复给了。最后再次感谢大家
      

  7.   

    帮帮忙!!!!!
    俺也急需一个支持中文的jar
    能给发一个吗???
    [email protected]
    谢谢谢谢!!!!!!!
      

  8.   

    兄弟们,也给我发一份吧。也是急用!!![email protected]
      

  9.   

    我也想要 [email protected] 谢谢!!
      

  10.   

    zzj9898我也要一个饿 ,急啊!
     [email protected]
      

  11.   

    ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲去下面地址下载 SmartUpload 上传组件(中文终极解决版)即可 
    http://download.csdn.net/source/608182▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
      

  12.   

    谁有jspSmartUpload.jar包,能给我发一个吗?找了许久了,谢谢了,[email protected]
      

  13.   

    谁有也给我发一个吧
    [email protected]