字符串拼接的順序html
當拼接字符串的時候要寫在裏面 由thymeleaf 維護會比較好url
<p th:text="'商務網址:' + ${enterprise.businessUrl != null ? enterprise.businessUrl : ''}"> </p>
或者這樣寫由SpringEL引擎負責spa
<p th:text="${enterprise.contactsMobile!=null}?'聯繫方式:'+${enterprise.contactsMobile}:'聯繫方式:'">聯繫方式: </p>
這兩種寫法都比較穩!code
這樣的話 若是爲空的話就只會顯示 商務網址:htm
其餘的寫法的話就會出現 前面的字符不顯示的狀況。圖片
圖片url引用字符串
<img src="images/mr1_img.jpg" th:src="@{${enterprise.enterprisePicture}}" />
<a>標籤URL引用get
<a th:href="${enterprise.creditUrl != null ? enterprise.creditUrl : ''}">
或者相似圖片URl 的引用方式it
<a th:href="@{http://{url}(url=${enterprise.businessUrl})}">
給某個文字加上連接(<a>)class
把<a>標籤寫在thymeleaf 裏
<h2 th:utext="${enterprise.enterpriseName != null ? '<a href=' + enterprise.creditUrl + '>' + enterprise.enterpriseName + '</a>' : ''}">
或者 本身寫在html
<a th:href="${enterprise.creditUrl != null ? enterprise.creditUrl : ''}"> <h2 th:text="${enterprise.enterpriseName}">珠海匯豐徵信有限公司</h2> </a>
2018-2-2新增
方法中加入字符參數(url)
<button class="bu3" th:onclick="'locateTo("/myref/list?id=' + ${targetId} + '")'">個人關聯</button>
" -> "
方法傳遞多個變量參數
th:onclick="'addRef('+${targetId}+','+${wantRef.id} +')'"
內嵌頁面(把公共頁面提取出來,經過引入加入)
一、新建一個頁面 , 加入錨點 th:fragment
二、在須要的位置經過 th:include 引入