I ran the spring-boot-sample-web-static project from here, made this alteration to the pom
org.springframework.boot&l
As it is written before, some folders (/META-INF/resources/, /resources/, /static/, /public/) serve static content by default, conroller misconfiguration can break this behaviour.
It is a common pitfall that people define the base url of a controller in the @RestController annotation, instead of the @RequestMapping annotation on the top of the controllers.
This is wrong:
@RestController("/api/base")
public class MyController {
@PostMapping
public String myPostMethod( ...) {
The above example will prevent you from opening the index.html. The Spring expects a POST method at the root, because the myPostMethod is mapped to the "/" path.
You have to use this instead:
@RestController
@RequestMapping("/api/base")
public class MyController {
@PostMapping
public String myPostMethod( ...) {