HyewonJu
HyewonJu

Reputation: 3

image not displaying on Web page in Spring boot application

I use thymeleaf template engine and place the files like that. but images do not display on Web page. how can i fix it? place files like this result

<span class="Google">
    <a href="">
        <img src="img/google.png">
    </a>
</span>

<span class="kakao">
    <a href="">
        <img src="img/kakao.png">
    </a>
</span>

Upvotes: 0

Views: 1297

Answers (2)

shubham gulati
shubham gulati

Reputation: 101

put / at the start of url and make sure .png should be present at /resource/static/img/ directory

try this

<span class="kakao">
    <a href="">
        <img src="/img/kakao.png">
    </a>
</span>

Upvotes: 1

Tonny Tc
Tonny Tc

Reputation: 930

I may change the image reference to:

<img th:src="@{/img/google.png}">

It will add context-relative url to the image's uri.

Here is the document.

Upvotes: 0

Related Questions