Reputation: 954
I am new to Spring Boot and I am trying to add a simple html page for my project At the moment, my project's structure is the following:
Having read the following: https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot
and other answers in StackOverflow, I'd expect to see the contents of index.html when I visit http://localhost:8080/
What could I be missing?
Upvotes: 7
Views: 22536
Reputation: 954
First of all the correct way to serve files in Spring Boot is described in cannot find html pages with spring boot
After adding the directories required, I tried /services/login.html
where "services" is the mapping for my Dispatcher servlet.
So what happens here is that Spring Boot will only answer to requests sent to /services/* even if these requests are pointing to something other than a controller.
I guess that this makes sense in the world of Spring Boot but when I tried in the same in a Spring MVC project (no Spring Boot) I was able to access simple html files that I had simply added into my WEB-INF directory
Upvotes: 1
Reputation: 1476
As there is no webapp in SpringBoot project , we can place the html files in either in
src/main/resources/resources/index.html
src/main/resources/static/index.html
src/main/resources/public/index.html
Remember the above is in highest to lowest precedence.
To check your file run the main class in eclipse and go to http://localhost:8080/index.html
Upvotes: 2