1. 程式人生 > >springboot+springcloud+vue學習(三)

springboot+springcloud+vue學習(三)

thymeleaf模板 :(前端了解不多,主要使用vue,後期再做介紹)

springboot 對jsp不是很友好,官方推薦使用thymeleaf模板

Thymeleaf最大的特點是能夠直接在瀏覽器中開啟並正確顯示模板頁面,而不需要啟動整個Web應用。

需要特別注意的是Thymeleaf對於URL的處理是通過語法@{…}來處理的。Thymeleaf支援絕對路徑URL:<a th:href="@{http://www.thymeleaf.org}">Thymeleaf</a>

條件求值:<a th:href="@{/login}" th:unless=${session.user != null}>Login</a>

 

for迴圈:

 <tr th:each="prod : ${prods}">    

  <td th:text="${prod.name}">Onions</td>      

  <td th:text="${prod.price}">2.41</td>      

  <td th:text="${prod.inStock}? #{true} : #{false}">yes</td>
</tr>

WebJars 可以將前端的css,JavaScript等資源打成前端資源包jar 供使用,非常方便簡潔