ext中窗口中显示了图片,
然后增加一个按钮“另存为”,点击按钮将图片保存到本地。

解决方案 »

  1.   

    //文件下载   什么文件都可以. 
    String   downFile   =   request.getParameter( "file ");       
          if(downFile!=null&&!downFile.equals( " ")){ 
                String   filename   =   downFile.substring(downFile.lastIndexOf( "\\ ")+1); 
                downFile   =   new   String(downFile.getBytes( "ISO-8859-1 "),   "GB2312 "); 
    //String   filename   =   downFile.substring(downFile.lastIndexOf( "\\ ")+1); 
    BufferedInputStream   bis   =   new   BufferedInputStream(new   FileInputStream(downFile)); 
    byte[]   buf   =   new   byte[1024]; 
    int   len   =   0; 
    OutputStream   os   =   response.getOutputStream(); 
    response.reset();   //非常重要 //纯下载方式 
    response.setHeader( "Content-Disposition ",   "attachment;   filename=\ " "   +   filename+ "\ " ");   
    response.setContentType( "bin;charset=iso8859_1 ");   while((len   =   bis.read(buf))   > 0)   os.write(buf,0,len); 
    System.out.println(userIp+ ":下载: "+filename); 
    bis.close(); 
    os.close(); 
    }