Java Spring with mustache keeps looking for files on server

I've been trying to develop a quick website using Java Spring with Mustache for templating but I have an issue when it comes to getting local files (css stylesheets or images). I'm running the website on intelliJ on http://localhost:8000 and for some reason it looks for every files on http://localhost:8000/Path/to/the/file and returns a 404 error on the inspector (no error in the console log)

Here are my file-tree and the code I'm using. The templates .mustache are in the templates directory.

filetree

<nav class="level">
    <div class="level-left">
        <div class="level-item">
            <img src="/img/flags/gb.svg"/>
        </div>
        <div class="level-item">
            <img src="/img/flags/fr.svg"/>
        </div>
        <div class="level-item">
            <img src="/img/flags/es.jpg"/>
        </div>
        <div class="level-item">
            <img src="/img/flags/ch.svg"/>
        </div>
        <div class="level-item">
            <img src="/img/flags/de.svg"/>
        </div>
    </div>
</nav>

I saw some posts telling to add a resource handler like this :

registry.addResourceHandler("/css/**").addResourceLocations("/resources/static/css");
registry.addResourceHandler("/img/**").addResourceLocations("/resources/static/img");
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/static/");

But no luck so far. Any help would be appreciated.

1 answer