Skip to content Skip to sidebar Skip to footer

Thymeleaf, IntelliJ And Spring Boot Not Loading CSS Files Correctly

I have been experiencing this issues and each time, I only resolve it by creating a new project which appears to work. This time I intend to find out why this happens or I encounte

Solution 1:

I was able to solve the problem after a series of test to produce this problem. The problem arises when I leave my mappings general as in allowing my controller to map directly to the root mapping.

Example is

@GetMapping // Here is the problem... This was the only method in the controller
public String home() {
  return "index";
}

I fixed this by setting a mapping like

@GetMapping(value= "/")
public String home() {
   return "index";
}

or by using the Class Level Mapping

@RequestMapping(value= "/")
public class Controller {

   public String home() {
     return "home";
   }

}

Post a Comment for "Thymeleaf, IntelliJ And Spring Boot Not Loading CSS Files Correctly"