如果启动类已经放在根路径,并且总pom.xml也已经导入freemarker的依赖项:
那就有可能是没有在application.yml文件中配置模板文件目录和模板文件结尾,引入:
spring:
freemarker:
allow-request-override: false
cache: false
check-template-location: true
charset: UTF-8
content-type: text/html; charset=utf-8
expose-request-attributes: false
expose-session-attributes: false
expose-spring-macro-helpers: false
## 模版文件结尾.ftl
suffix: .ftl
## 模版文件目录
template-loader-path: classpath:/templates
打开网页成功显示: