Placing Static Files in Spring Boot

Placing Static Files

Folder Structure

|-build.gradle
`-src/main/resources/
  |-static/
  | `-static.html
  |-public/
  | `-public.html
  |-resources/
  | `-resources.html
  `-META-INF/resources/
    `-m-resourceshtml

Each HTML file contains plain text with its file name.

Starting the Application

Start Spring Boot with this structure and use the files as follows:

$ curl http://localhost:8080/static.html
static.html

$ curl http://localhost:8080/public.html
public.html

$ curl http://localhost:8080/resources.html
resources.html

$ curl http://localhost:8080/m-resources.html
m-resources.html

Accessing Static Files

Files placed in the following classpath folders can be accessed as static files:

  • static
  • public
  • resources
  • META-INF/resources