Thymeleaf模板语法

循环:

循环:th:each="yiji:${hdaohangs}"

链接:th:href="@{${erji.dhurl}}"

判断:th:if="${erji.dhpid} == ${yiji.dhid}"

显示文字:th:text="${yiji.dhname}"

不改变原来class添加新的class:th:classappend="${(sanji.dhpid == erji.dhid ? 'ulxianshi': 'ulyincang')}"

<div class="collapse navbar-collapse" id="navbar-menu">
    <ul class="sina-menu" data-in="fadeInLeft" data-out="fadeInOut">
        <li class="dropdown aa"  th:each="yiji:${hdaohangs}">
            <a th:href="@{${yiji.dhurl}}" th:text="${yiji.dhname}" class="dropdown-toggle" data-toggle="dropdown" ></a>
            <ul class="dropdown-menu " >
                <li class="dropdown" th:each="erji:${leveltwo}" th:classappend="${(erji.dhpid == yiji.dhid ? 'ulxianshi': 'ulyincang')}">
                    <a th:href="@{${erji.dhurl}}"  th:if="${erji.dhpid} == ${yiji.dhid}" th:text="${erji.dhname}" class="dropdown-toggle" data-toggle="dropdown" ></a>
            <ul class="dropdown-menu" >
                <li th:each="sanji:${levelthree}" th:classappend="${(sanji.dhpid == erji.dhid ? 'ulxianshi': 'ulyincang')}">
                    <a th:if="${sanji.dhpid} == ${erji.dhid}" th:text="${sanji.dhname}" >           
                    </a>
                 </li>
            </ul>
                </li>
            </ul>
        </li>
    </ul>
</div>

图片:

图片:th:src="@{${neiya.newfengmian}}" 

图片截取字符串:th:src="@{${#strings.substringAfter('__${neiya.newfengmian}__','D')}}" 

字符串截取,后面到结尾:th:text = ${#strings.substringAfter('__${user.agencObj}__',',')} 

<img th:src="@{${neiya.newfengmian}}"  alt="" class="img-fluid" />
<img th:src="@{${#strings.substringAfter('__${neiya.newfengmian}__','D')}}"  alt="" class="img-fluid" />

 

 

 

 

上一篇:DSO学习笔记六 initializeFromInitializer函数


下一篇:thymeleaf 使用th:onclick传递参数问题: