thymeleaf中fragments的用法
最近在学习前台的模板引擎,看到thymeleaf中有一个说明,在不启动服务的情况下,就可以直接查看页面的修改结果。
但是自己用了下面的一段代码,启动服务之后可以正常显示。在不启动服务的情况下,直接通过浏览器启动index.html,页面不能正常显示。
---------------------------------------------------------
footer.html的内容:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<div th:fragment="copy">
© 2011 The Good Thymes Virtual Grocery
</div>
</html>
---------------------------------------------------------
index.html的内容:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
测试
<div th:replace="footer :: copy"></div>
</body>
</html>
---------------------------------------------------------
上面的两个文件,在启动tomcat服务器之后,页面可以正常显示。显示内容如下:
测试
© 2011 The Good Thymes Virtual Grocery
如果不启动tomcat服务器,直接用浏览器打开index.html,显示内容如下:
测试
fragments的内容没有表示出来。请问是怎么回事?
不启动服务的情况下,fragments的可以正常显示吗?