Question

I developed a component in ZK 7.0.0 with own molds, styles etc. The component should be build in one jar file, which I can copy in WEB-INF/lib folder to replace standart ZK components.

Folder structure:

  • src/
  • src/main/resources/web/images/
  • src/main/resources/web/js/

In ".css.dsp" files I use statements likes:

background-image:url(${c:encodeURL('/images/in2.png')}

And it's refer to 'domen/webapp/images/in2.png'. (physical path: /webapp/images/in2.png). But I need get images from jar file.

So how can I write relative path to images in css files?

Was it helpful?

Solution

You are faced with the case that is somewhat similar to this one.

To reference a URI that points to a file on the classpath you should use a special prefix ~./:

background-image:url(${c:encodeURL('~./images/in2.png')}

Some more details could be found in the docs for methods WebApp.getResource or Execution.locate. Real world examples can be seen in ZK source files.

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