spring-bootstatic-resource

spring boot static resource 404 error


I am studying spring boot. And now I have to deploy my static resources to the web project, linking it, but it returns 404 error

enter image description here

Also, when I access to "localhost:8080/appie/resources/js/common.js" browser returns 404 error(my context path is /appie).

What could be that reason?

server.contextPath=/appie

Solution

  • Spring Boot by convention serves static resources under src/main/resources/static. The path of the resource will be relative to this, so if you put common.js under static resources, you will be able to access to it in: localhost:8080/appie/common.js

    To access to it in as resources/js/common.js create this folder structure under static.