Thymeleaf學習記錄(5) 運算及表單

2022-08-26 17:48:22 字數 1907 閱讀 9224

thymeleaf文字及預算:

文字操作:

算術運算:

布林運算:

比較和等價:

示例如下:

表單提交

增加subscribe.html頁面:

內容如下:

doctype html

>

<

html

lang

="en"

>

<

head

>

<

meta

charset

="utf-8"

>

<

title

>title

title

>

head

>

<

body

>

<

form

action

="#"

th:action

="@"

th:object

="$"

method

="post"

>

<

fieldset

>

<

input

type

="text"

name

="name"

/>

<

input

type

="submit"

value

="名稱提交"

/>

fieldset

>

form

>

<

form

th:attr

="action='#',action=@,object=$,method='post'"

>

<

fieldset

>

<

input

type

="text"

name

="age"

/>

<

input

type

="submit"

value

="年齡提交"

/>

fieldset

>

form

>

body

>

html

>

如下所示:

後台controller增加:

public

string getsubscribe( )

public

string getpage1byname(@modelattribute user user)

如下所示:

執行結果:

名稱提交:

年齡提交:

thymeleaf學習筆記

thymeleaf 學習簡單記錄,其中使用springboot 配置server.servlet.context path thy href details.html th href viewa href details.html th href viewa href details.html th...

Thymeleaf學習筆記 二)

語法 含義 預設呼叫轉換函式,將其轉換為string 示例 語法 含義 在預處理階段,替換為對應的message information,基於locale 示例 th text some text here.語法 th attr attrname 含義 設定節點中特定屬性的值 示例 th attr ...

Thymeleaf學習筆記 三

1 定義fragment 語法 th fragement 示例 xmlns th th fragment copy div body html fragmeng使用示例 footer copy 下面是乙個動態的模板fragment示例 footer.admin 上述示例中,功能強大,可以實現動態的f...