0
点赞
收藏
分享

微信扫一扫

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

JamFF 2022-03-26 阅读 47

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