thymeleaf 語法——input、select、radio、textarea 回顯

input :

<input type="text" id="name" name="name" th:value="${user.name}" class="form-control1"  >

select :

<label  class="col-sm-4 control-label">類別</label>
<div class="col-sm-8">
    <select  id="cId" name="cId"  class="form-control1" >
        <option value="1" th:field="*{book.cId}">目錄1</option>
        <option value="2" th:field="*{book.cId}">目錄2</option>
        <option value="3" th:field="*{book.cId}">目錄3</option>
        <option value="4" th:field="*{book.cId}">目錄4</option>
    </select>
</div>

說明:{ } 中,變量名前後不得出現空格,如 { book.cId}、 {book.cId }、 { book.cId },將拋出模板解析錯誤 。

radio:

<label for="isDel" class="col-sm-4 control-label">是否刪除</label>
<div id="isDel" class="col-sm-8">
    <div class="radio-inline">
        <label><input type="radio" name="isDel"  value="1"  th:field="*{user.isDel}"/>已刪除</label>
    </div>
    <div class="radio-inline">
        <label><input type="radio" name="isDel"  value="0"  th:field="*{user.isDel}"/>正常</label>
    </div>
</div>

說明:{ } 中不得出現空格,如 { book.cId}、 {book.cId }、 { book.cId },將報模板解析錯誤 。

textarea :
內容:

<textarea  id="content" name="content" th:text="${user.content}"  ></textarea>

使用 th:value 不能回顯。
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章