2011-11-28 73 views
0

根據我們的實施,我們動態地在服務器端創建一些圖像文件並共享URL。
但是,如果在JETTY運行時創建文件,我們將無法使用URL檢索圖像資源。在碼頭加載動態文件

但是,如果我們停止碼頭並重新開始,我們可以檢索它。

我想知道是否有任何配置使我們能夠在沒有停止碼頭的情況下檢索資源?

回答

0

是否有必要堅持動態圖像?如果沒有,你可以只流這樣的動態圖像:


    public void sendImage(RenderedImage image, String mimeType, String imageIOType, HttpServletResponse response) 
    { 
     if(image != null) 
     { 
      OutputStream output = null; 
      try 
      { 
       output = response.getOutputStream(); 
       response.setContentType(mimeType); 
       ImageIO.write(image, imageIOType, output); 
      } 
      catch (IOException e) 
      { 
       e.printStackTrace(); 
      } 

      if(output != null) 
      { 
       try 
       { 
        output.flush(); 
        output.close(); 
       } 
       catch (IOException e) 
       { 
        e.printStackTrace(); 
       }    
      } 
     } 
    } 

HTH