使用模板异常的解决

Spring Boot 官网的介绍推荐的模板引擎Thymeleaf。

Spring Boot项目出现的异常:

template might not exist or might not be accessible by any of the configured Template Resolvers

中文译为:

模板可能不存在,也可能无法被任何配置的模板解析器访问。

具体表现为:

出现的原因:

这些肯定都是路径的问题

1、不是这个 templates 这个名字没命名正确;

2、就是在引入 JS文件时的路径没写对。。

要好好检查自己写的路径哦。。。。。

更深入的了解这个路径:

1、Thymeleaf这个模板的默认配置是:

  prefix:classpath:/templates/

  所以你的页面文件一定一定要写在这个文件夹内

2、th:include引入公共模板时注意头部不要加"/"

解决的方法:

 了解了原因,那我们就按照相应的原因来找自己的错误了。

 如果你的情况和我的一样,问题就快要解决了。。

原文地址:https://www.cnblogs.com/stujike/p/8677288.html