开发者

In a GWT UiBinder template with an image resource, where should I locate the actual image file?

According to the docs, you can add an image resource to be used in a uibinder template like this:

public interface Resources extends ClientBundle {

  @Source("Logo.jpg")
  ImageResource logo();

  ...
}

Using this example as is, however, the image file (Logo.jpg) must be included in the same directory/package as Resources.java. Where should I put my image file and how should I list the file path so that I don't have to keep the image file in my src tree? Specifically, I'm using maven - don't I want my images in src/main/webapp, not开发者_如何学C in src/main/java/com/mygwtapp/client?


You can provide a relative path for your images like this:

@Source("../../resources/images/Logo.jpg")
ImageResource logo();

The path is relative to where your Resources interface is located. And ../ stands for parent directory.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜