iT邦幫忙

0

Day 7 - Thymeleaf 樣板引擎基礎:讓醫療數據與 HTML 完美融合

  • 分享至 

  • xImage
  •  

今日目標
在 Spring Boot 專案內設定 Thymeleaf,讀取 src/main/resources/templates 下的 HTML。

核心概念
Thymeleaf 是 Server-side 渲染引擎,能將 Spring 傳遞的 Model 資料綁定到 HTML 標籤上。

實作程式碼 (HTML 擷取)

<h1>受檢者:<span th:text="${patient.name}">預設名字</span></h1>
<p>檢驗日期:<span th:text="${#temporals.format(reportDate, 'yyyy-MM-dd')}"></span></p>

心得
Thymeleaf 的語法非常直覺,與原本的 HTML 標籤融合得很好,即使沒有啟動後端,前端也能直接預覽版型。


圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言