问题
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?
回答1:
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"/>
来源:https://stackoverflow.com/questions/40771002/how-to-reference-an-img-in-pgraphicimage-from-the-resource-folder