4

I have an image in the following path:

resources
\_____img
 \_______sites
  \_______reddit.png

I used this command line to reference it:

<p:graphicImage library="img" name="/sites/reddit.png"/>

but in the development console it says:

GET http://localhost:8080/RES_NOT_FOUND 404 ()

and the image is not rendered.

What's wrong?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
TonyRomero
  • 182
  • 1
  • 4
  • 14
  • Offtopic: http://stackoverflow.com/questions/11988415/what-is-the-jsf-resource-library-for-and-how-should-it-be-used – Kukeltje Nov 23 '16 at 17:44
  • the `resources` folder is under WEB-INF, but it always fails to render the image. please help, that topic isn't helpful. – TonyRomero Nov 23 '16 at 18:11

1 Answers1

6

Kukeltje's suggested url (What is the JSF resource library for and how should it be used?) is definitive resource to resolve this issue.

Based on that URL, I think the resources folder should not be under WEB-INF. It should have a structure as follows assuming that you are using a default maven project layout

src/main/webapp/resources
-------------------------/img
-----------------------------/sites
-----------------------------------/reddit.png
src/main/webapp/WEB-INF
-----------------------/web.xml

Then the following JSF construct should work.

<p:graphicImage library="img" name="sites/reddit.png"/>
Community
  • 1
  • 1
Doraemon
  • 305
  • 3
  • 8