Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSP with CSS does not display the background image

I have the following directory structure

structure http://img853.imageshack.us/img853/7092/96816871.jpg

My CSS tries to use an image as a background

#search-text {
width: 213px;
height: 28px;
padding: 6px 0 0 7px;
border: none;
background: url(../images/img02.jpg) no-repeat left top;
color: #000000;

}

and it doesn't work while other parts of css work fine.

Firebug shows that application tries to access image by URL _http://localhost:8080/images/img02.jpg and gets 404 error

When I try to access image directly I also get this error. Also I tried _http://localhost:8080/paygate/images/img02.jpg _http://localhost:8080/paygate/resources/images/img02.jpg ...and this error doesn't stop follow me.

When I've changed my CSS file to the following

background: url(images/img02.jpg) no-repeat left top;

warning appeared in webserver log:

WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/paygate/images/img02.jpg] in DispatcherServlet with name 'appServlet'

and Firebug showed 404 error for URL _http://localhost:8080/paygate/images/img02.jpg

How should I organize my directory structure or what should I do to make my images accessible. Thank's!

P.S. I'm using springsource tc server as a webserver.

like image 625
Greg Avatar asked Sep 15 '25 16:09

Greg


1 Answers

According to your project structure, the .css file and images folder is in the same level, So:

background: url(images/img02.jpg) no-repeat left top;

will work.

like image 194
Genzer Avatar answered Sep 17 '25 06:09

Genzer