thymeleaf基本语法
需要判斷HashMap中是否存在對應(yīng)的key,如果存在,則取出并輸出,如果不存在,輸出空
th:value="${#maps.containsKey(searchMap,‘keywords’)? searchMap.keywords:’’}"
unless,包含則不執(zhí)行
th:unless="${#maps.containsKey(searchMap,‘category’)}"
src圖片:
th:src="${item.image} "
utext會識別相關(guān)的標(biāo)簽,abbreviate:截取對應(yīng)的字符:
th:utext="${#strings.abbreviate(item.name,100)}"
@{}里面寫url地址,如果需要添加參數(shù),則在url地址后面添加()
th:href="@{url地址(category=KaTeX parse error: Expected 'EOF', got '}' at position 12: {category})}?" th:href="@{{url}(category=${category})}"
字符串替代
th:text="${#String.replace(spec.key,‘spec_’,’ ')}"
字符串以xxx開頭
th:if="${#strings.startsWith(spec.key,‘spec_’)}"
總結(jié)
以上是生活随笔為你收集整理的thymeleaf基本语法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql的存储过程基本使用
- 下一篇: 网关限流令牌桶