springboot+thymeleaf视图映射报错:There was an unexpected error (type=Not Found, status=404)
在springboot上使用thymeleaf框架搭建前端时,新手可能会出现Whitelabel Error Page,404的问题。
查找了很多网上资料,指出要么是配置问题,要么是没有导入依赖,都没能解决问题。
其实如果使用thymeleaf,问题基本是不会出在配置上的,最可能的原因其实是出在依赖上面,但不是有没有导入的问题,而是导入的依赖是哪个版本的问题。比如我原先在pom.xml文件中导入的thymeleaf版本是:
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring4</artifactId> <!-- 如果spring是5:thymeleaf-spring5 -->
<version>3.0.9.RELEASE</version>
</dependency>
结果是会报错的。
而后来改成下面springboot的thymeleaf版本后:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
结果是成功的。
当然,在前面一个版本有提到“如果spring是5:thymeleaf-spring5”,按道理来说,我的spring版本是5,应该是可以编译成功的,但实际上,改成thymeleaf-spring5后却是没法通过构建的,具体原因不清楚。
因此,为了保险起见,各位在springboot中使用thymeleaf时最好还是直接使用spring-boot-starter-thymeleaf这种版本,让它自动判断所需的版本,省的各种麻烦。
上一篇: springboot集成jsp,There was an unexpected error (type=Not Found, status=404). No message available
下一篇: 小白踩坑记:springboot运行一直报错:There was an unexpected error (type=Not Found, status=404).
推荐阅读
-
thymeleaf 404报错:There was anunexpected error (type=Not Found, status=404).
-
spring boot jst 模板报404 There was an unexpected error (type=Not Found, status=404).
-
There was an unexpected error (type=Not Found, status=404)---采用layui出现的问题
-
idea:springboot整合jsp出现的错误:There was an unexpected error (type=Not Found, status=404). /WEB-INF/jsp。。
-
springboot中unexpected error (type=Not Found, status=404)/WEB-INF/upload.jsp和No message available解决方案
-
Whitelabel Error Page There was an unexpected error (type=Not Found, status=404). No message availab
-
浏览器请求spring-boot模块项目报:There was an unexpected error (type=Not Found, status=404).
-
springboot集成jsp,There was an unexpected error (type=Not Found, status=404). No message available
-
springboot+thymeleaf视图映射报错:There was an unexpected error (type=Not Found, status=404)
-
小白踩坑记:springboot运行一直报错:There was an unexpected error (type=Not Found, status=404).