Error resolving template [/common/head], template might not exist or might not be accessible by any

蔚落 2023-10-10 11:24 171阅读 0赞

SpringBoot1.5.x 集成Thymeleaf2.1.x 使用公共页面,提示如下错误信息:

  1. Error resolving template [/common/head], template might not exist or might not be accessible by any

thymeleaf 需要注意配置:

  1. # 访问template下的html文件需要配置模板,映射
  2. spring.thymeleaf.prefix.classpath=/templates

thymeleaf 报错写法:

  1. <head th:replace="~{common/head}">
  2. <meta charset="UTF-8"/>
  3. <title>图书管理系统</title>
  4. <link rel="stylesheet" href="../static/css/bootstrap.min.css"/>
  5. <script src="../static/js/jquery-3.3.1.min.js" ></script>
  6. <script src="../static/js/popper.min.js" ></script>
  7. <script src="../static/js/bootstrap.min.js"></script>
  8. </head>

thymeleaf 正确写法:

  1. <!doctype html>
  2. <html lang="en">
  3. <head th:replace="common/head::head">
  4. <meta charset="UTF-8"/>
  5. <title>图书管理系统</title>
  6. <link rel="stylesheet" href="../static/css/bootstrap.min.css"/>
  7. <script src="../static/js/jquery-3.3.1.min.js" ></script>
  8. <script src="../static/js/popper.min.js" ></script>
  9. <script src="../static/js/bootstrap.min.js"></script>
  10. </head>

发表评论

表情:
评论列表 (有 0 条评论,171人围观)

还没有评论,来说两句吧...

相关阅读