SpringBoot with Thymeleaf - css not found

后端 未结 6 1977
没有蜡笔的小新
没有蜡笔的小新 2020-12-06 06:15

First to say is that I\'ve been searching for a solution for a while now and I\'m quite desperate now.

I cannot get the css file to be accessible from html page when

6条回答
  •  没有蜡笔的小新
    2020-12-06 06:29

    The problem was the @EnableWebMvc annotation in the Application.java file. As soon as I removed that one, the css started to be available at localhost:8080/css/style.css but was not applied. So far I haven't found the reason why the @EnableWebMvc was causing the problem.

    Then I removed a controller mapped to /** that I had implemented in order to display custom error page.

    @RequestMapping("/**")
    public String notFound() {
        return "errors/404";
    }
    

    After removing also this one, I've got my css working. =)

提交回复
热议问题