使用
常见替换标签,例如th:text,th:href
<script th:src="@{/plugins/jquery/jquery.min.js}"></script>单独使用变量:
[[${content.views}]]each
<div class="block-thumb" th:each="content,arrayS:${contents}">
...
</div>if判断List不是空
<li class="list-group-item" th:if="${!recommendContents.isEmpty()}">
...
</li>if判断字符不是空
<li class="list-group-item" th:if="!${#strings.isEmpty(optionsMap.location)}">
...
</li>拼接
<div class="block-thumb2" th:style="'background-image:url('+${content.thumb}+')'">
...日期格式化
<time>[[${#dates.format(content.createdTime, 'yyyy-MM-dd')}]]</time>application域对象
// 后端传值
request.getServletContext().setAttribute("username", "admin");
//前端取值
${#servletContext.getAttribute('username')}字符串常见使用方法
https://blog.csdn.net/qq_33535433/article/details/78876693
前端获取session里对象属性
session.setAttribute("USER_SESSION", user);th:value="${session.USER_SESSION.mail}js函数传值通过Thymeleaf
th:onclick="valuesToInput([[${category.cgid}]],[[${category.cgName}]],[[${category.cgSlug}]])"拼出绝对路径
<a th:href="${#httpServletRequest.getScheme() + '://' + #httpServletRequest.getServerName() + ':' + #request.getServerPort() + #request.getContextPath() + @{/login}} ">点我啊!</a>getScheme()获取协议
getServerName()获取服务器名
getServerPort()服务器端口
getContextPath() APP根路径

新年快乐!
涨知识了 赞一个