ssh框架commons-io包的下载对话框如何弹出,就是点击下载弹出要下载东西的保存路劲。
我会JFrame的但是太丑了java

解决方案 »

  1.   

    你想多了,那个下载对话框是浏览器自己的组件。你拿Jframe写的东西能在客户的浏览器运行?你给它做成Applet了?
      

  2.   

    给你一个,我在项目中用的,OutputStream out=response.getOutputStream();
    response.setContentType(document.getContentType());
    // System.out.println(document.getFileName());
    // response.setCharacterEncoding("utf-8"); 
    String downName=new String(document.getFileName().getBytes("gbk"),"iso8859-1");
    response.setHeader("Content-Disposition", "attachment;fileName="+downName);
    InputStream input=document.getContent().getBinaryStream();
    // int a;
    // while((a=input.read())!=-1){
    // out.write(a);
    // }
    IOUtils.copy(input,out);
    out.flush();
    out.close();
    input.close();