Error resolving template [/common/head], template might not exist or might not be accessible by any解析
虾米哥
阅读:376
2021-03-31 13:46:23
评论:0
SpringBoot1.5.x 集成Thymeleaf2.1.x 使用公共页面,提示如下错误信息:
Error resolving template [/common/head], template might not exist or might not be accessible by any
thymeleaf 需要注意配置:
# 访问template下的html文件需要配置模板,映射
spring.thymeleaf.prefix.classpath=/templates
thymeleaf 报错写法:
<head th:replace="~{common/head}">
<meta charset="UTF-8"/>
<title>图书管理系统</title>
<link rel="stylesheet" href="../static/css/bootstrap.min.css"/>
<script src="../static/js/jquery-3.3.1.min.js" ></script>
<script src="../static/js/popper.min.js" ></script>
<script src="../static/js/bootstrap.min.js"></script>
</head>
thymeleaf 正确写法:
<!doctype html>
<html lang="en">
<head th:replace="common/head::head">
<meta charset="UTF-8"/>
<title>图书管理系统</title>
<link rel="stylesheet" href="../static/css/bootstrap.min.css"/>
<script src="../static/js/jquery-3.3.1.min.js" ></script>
<script src="../static/js/popper.min.js" ></script>
<script src="../static/js/bootstrap.min.js"></script>
</head>
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。