Background image does not appear when running the project

Asked

Viewed 1,093 times

1

I have a JSF+Primefaces project and I have a css that puts a background:

<h:body 
    style="background-image: url('../images/textura.jpg');">

When I run the page works perfectly, but when I give a run on the project the image does not load, it only loads after some operation is performed.

Anyone can help?

1 answer

1


Probably the image path. I recommend leaving images in the system’s Resources folder. Example : resources/images. Thus using the #{resource[]} it takes the root path to the folder. Example:

 background-image: url("#{resource['images/textura.jpg']}");
  • Is this Resources folder I should create? or is it SRC?

  • And when I put that inside a style of error

  • 1

    I created a css class and put this code. but if it’s inside a style, try using this style="background-image: url('#{resource['images/textura.jpg']}')". I created the folder manually.

  • I created the Resource folder in Webcontent, and put the code, the image does not appear

  • problem solved, I made a modification and it worked: background-image:url(#{request.contextPath}/resources/images/textura.jpg);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.