Springboot项目配置Freemarker模板报错:There was an unexpected error (type=Not Found, status=404)

JamFF

关注

阅读 48

2022-03-26

如果启动类已经放在根路径,并且总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

打开网页成功显示:
在这里插入图片描述

精彩评论(0)

0 0 举报