Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference an img in p:graphicImage from the resource folder [duplicate]

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?

like image 370
TonyRomero Avatar asked Oct 15 '25 04:10

TonyRomero


1 Answers

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"/>
like image 179
Doraemon Avatar answered Oct 18 '25 08:10

Doraemon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!