簡體   English   中英

頁面中外部資源的GIF在apache wicket Web應用程序中未設置動畫

[英]GIF from external resource in page is not animating in apache wicket web application

我在網絡應用程序中使用外部圖像,一切都很好,直到我想在那里添加動畫gif,gif加載完畢,但它沒有動畫。

Java代碼:

    File sourceimage = new File("loading_img.gif");

    try {
        final BufferedDynamicImageResource r = new BufferedDynamicImageResource("GIF");
        r.setImage(ImageIO.read(sourceimage));
        add(new Image("gif",  r));

    } catch (Exception e) {
        e.printStackTrace();
    }

HTML:

                <img wicket:id="gif"/>     

編輯:

嘗試使用Martin-G建議,GIF仍然沒有動畫

      try {
          final BufferedDynamicImageResource r = new BufferedDynamicImageResource("GIF"){
              @Override
              protected void setResponseHeaders(AbstractResource.ResourceResponse data,
                      IResource.Attributes attributes){
                  super.setResponseHeaders(data, attributes);
                  data.setContentType("image/gif");
              }
              };
          r.setImage(ImageIO.read(sourceimage));
          add(new Image("gif",  r));

      } catch (Exception e) {
          e.printStackTrace();
      }

問題是內容類型沒有自動設置。 您將需要重寫org.apache.wicket.request.resource.AbstractResource#setResponseHeaders()並通過resourceResponse.setContentType(String)

也許應該由Wicket在org.apache.wicket.request.resource.DynamicImageResource中自動完成,因為它知道格式(如您的情況那樣為“ png”或“ gif”)。 請為此改進在Wicket的JIRA中提交票證! 謝謝!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM