how to load a svg in gwt widget from an url

后端 未结 2 1691
刺人心
刺人心 2021-01-24 09:05

I have a servlet that delivers png and svg images. With png i have no problem:

Image image = new Image(GWT.getHostPageBaseURL() + token);

But h

2条回答
  •  生来不讨喜
    2021-01-24 09:55

    If you use a URL to load an image, you don't need any libraries at all. And you don't need a servlet to deliver them. Just add images to your /war/images folder. Then, in your GWT code:

    Image image = new Image();
    image.setUrl("images/myImage.svg");
    myPanel.add(image);
    

    You may want to add some logic for browsers that do not support svg files.

提交回复
热议问题