开发者

Smartgwt & gwt Show Image From External Folder

开发者 https://www.devze.com 2023-04-11 22:25 出处:网络
It is possible to show an image by directly typing Img image = new Image(); image.setSrc(\"photo.jpg\");

It is possible to show an image by directly typing

Img image = new Image();
image.setSrc("photo.jpg"); 

if photo.jpg is under "images" folder 开发者_开发技巧under Web-Content.

I have task to show an image which is in a folder on desktop, is that possible in any way? I did lots of research but not come to a solution. Thanks.

Smartgwt 2.4 Ubuntu 10.10 Gwt 2.2


If your structure is something like:

myproject
 |-->src
 |||||-->com.myproject
 |||||||||-->client, server, shared
 |-->war
 |||||-->images

...you would use images from the war/images folder in files within the client package by referencing them as images/image.png. So your code ought to look like:

image.setSrc("images/photo.jpg");

The path of the image is relative to the war directory.


The important thing is images must be beneath {webroot} however it is defined. In IntelliJ, The path of the image is relative to the default web directory , so not necessarily war.
If I had the reputation I'd post an image that would explain, but in lieu of that....

    GWTapp
      -+.idea
      -+src
         --+client
         --+server
         --+GWTapp.gwt.xml
      -+web
         --+images
           ---+black.gif
         --+WEB-INF
           ---+web.xml
         --+GWTapp.css
         --+GWTapp.html
         --+index.jsp
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号