Search code examples
javaimageapachewicketcontextpath

How do i link to my Image-Folder inside my Apache Wicket Application?


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.


Solution

  • It will work with (removed the leading slash)

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