- 在HTML文件中引入其他的HTML文件
<div th:replace="common/top::html"></div>
或者使用include
<div th:include="head::html"></div>
- 在作用域裏面取值
默認顯示request中數據,
顯示session中數據要加上 session前綴
顯示servletContext中數據要加上application前綴
request.setAttribute("requestAge", 100);
session.setAttribute("sessionName", "小明");
servletContext.setAttribute("applicationNum", 1);
--------------------------------------------------------------------------------------
request中:
<span style="color: red;" th:text="${requestAge}"></span><br />
session中:
<span style="color: red;" th:text="${session.sessionName}"></span><br />
servletContext中:
<span style="color: red;" th:text="${application.applicationNum}"></span><br />
如果是將一個對象保存在作用域中,取值是通過對象點屬性名
<span th:text="${session.currentUser.realName}"></span>