springboot的推薦模板引擎-Thymeleaf


1)添加對themeleaf的支持的依賴

 <!--Thymeleaf-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

2)在resources的templates目錄下新建currentTime.html

 

th:text的含義是把值顯示在當前的標簽內

字符串拼接采用雙豎||符號就可以

3)修改application.properties,添加如下配置

#thymeleaf 配置
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
#緩存設置為false,立即生效
spring.thymeleaf.cache=false

 輸入controller層的路徑就可以看到頁面效果

 


免責聲明!

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



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