Question

My Package-Structure looks like:

  • src/main/java
  • src/main/resources
  • src/test/java
  • src/test/resources
  • src/main/webapp/css
  • src/main/webapp/images
  • src/main/js
  • src/main/WEB-INF

My images are stored under src/main/webapp/images.

Now i want to dynamically link to a picture e.g.:

    Image picture = new Image("picture",
                    new ContextRelativeResource("/images/races/"
                            + dynamicPicture));

The Problem is, that my Application can't find /images/races/$dynamicPicture. How do i set the correct path to my image folder? The Appliation Server used is Jetty.

Was it helpful?

Solution 2

It will work with (removed the leading slash)

    Image picture = new Image("picture",
                new ContextRelativeResource("images/races/"
                        + dynamicPicture));

OTHER TIPS

Indeed, your code should work. Are you using Maven to manage your project and to start Jetty?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top