Thymeleaf設定任意屬性

2021-07-27 07:03:35 字數 504 閱讀 9431

thymeleaf通過th:attr屬性,可以設定任意的html屬性。

合適的配置下,模板渲染後,相應的屬性會被正確賦值

xml規範不允許重複設定相同的屬性,thymeleaf用「」分隔作為多個屬性同時設定的語法。

src=

"../../images/gtvglogo.png"

th:attr

="src=@,title=#,alt=#"

/>

輸出

src=

"/gtgv/images/gtvglogo.png"

title

="logo de good thymes"

alt="logo de good thymes"

/>

Thymeleaf 自動編譯設定

了方便每次修改html檔案都能實時重新整理,做一下更改。thymeleaf start spring.thymeleaf.mode html5 spring.thymeleaf.encoding utf 8 spring.thymeleaf.content type text html 開發時關閉快...

thymeleaf的特殊屬性賦值

在用thymeleaf時,遇到特殊屬性不知道該怎麼解決如下 問題2 要在td中寫值,直接在td上使用th text,td裡面的值引入值都會直接被覆蓋,如果使用th text 拼接thml 試過報錯。後來查資料說使用 th inline text 的意思是直接在 塊中呼叫值,用法 這種寫法不僅 把值顯...

工作備忘 設定任意控制項任意位置的圓角

關鍵 如下 self exitbtn layer.maskstobounds yes cashapelayer masklayer cashapelayer layer masklayer.path uibezierpath bezierpathwithroundedrect self exitbt...