thymeleaf依賴以及一些圖片、文件、cdn的導入問題


導入依賴

<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>

 

<html lang="en" xmlns:th="htttp://www.thymeleaf.org">

 

使用thymeleaf之前記得加上xmlns以及里面的內容 否則所有thymeleaf都不生效

導入本地文件包括jsc、ss、img、都需要在前面加上th:src然后用@{}把整個路勁包起來 link則在href中加th類似

<script type="text/javascript" th:src="@{../static/js/jquery-3.3.1.js}"></script>
<link th:href="@{/myuser/css/bootstrap.min.css}" rel="stylesheet">

 

文本:th:text轉義字符  即里面內容的標簽內容,th:utext不轉義字符

數組:<h3 th:each ="user:${user}" th:text="{$user}"></h3>

 使用<p th:text="${msg}" th:if="${not #string.isEmoty{msg}}"></p>  可以讓標簽在msg為空的時候不顯示這個<p>標簽這個里面的msg是在之前controller里面判斷密碼錯誤之后才賦值的。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM