- if 语句加单选框(th:if)
<label class="col-sm-2 control-label">状态<span style="color:red;">*</span>:</label>
<div class="col-sm-4">
<div th:if="${dismantleDiscloseBaseinfo.state==1}">
<input name="state" th:value="1" checked type="radio">启动</input>
<input name="state" th:value="2" type="radio">停用</input>
</div>
<div th:if="${dismantleDiscloseBaseinfo.state==2}">
<input name="state" th:value="1" type="radio">启动</input>
<input name="state" th:value="2" checked type="radio">停用</input>
</div>
</div>
th:if="${dismantleDiscloseBaseinfo.state==1}">
<input name="state" th:value="1" checked type="radio">启动</input>
<input name="state" th:value="2" type="radio">停用</input>
</div>
<div th:if="${dismantleDiscloseBaseinfo.state==2}">
<input name="state" th:value="1" type="radio">启动</input>
<input name="state" th:value="2" checked type="radio">停用</input>
</div>
</div>
利用 th:if="${code==''}" 进行判断 对加载里面数据,不对跳过。
- 多文本框 (th:text)
<div class="col-sm-12 demo-gallery" >
<div class="col-sm-2">
<textarea id="specialRequirements" name="specialRequirements" th:text="${techniqueDisclose.specialRequirements}"
class="form-control" rows="5" cols="210"
type="text" style="margin: 0px -865px 0px 0px; width: 1005px; height: 123px;" readonly></textarea>
</div>
</div>
th:text="${techniqueDisclose.specialRequirements}"
class="form-control" rows="5" cols="210"
type="text" style="margin: 0px -865px 0px 0px; width: 1005px; height: 123px;" readonly></textarea>
</div>
</div>
利用 th:text="${code}" 进行对多行文本框 加载model里面数据,readonly为直读。
- foreach 语句加图片(th:each)
<label class="col-sm-3 control-label" style="text-align:left;">图片详情<span style="color:red;">*</span>:</label> <hr> <div class="col-sm-12 demo-gallery" > <div class="col-sm-2" th:each="d:${techniqueDisclose.dismantleImgArray}"> <a th:href="${d}"data-size="1040x800" data-med="https://farm4.staticflickr.com/3894/15008518202_b016d7d289_b.jpg" data-med-size="824x600" data-author="Folkert Gorter" class="demo-gallery__img--main"> <img width="120" style="margin: 10px 0;background-color: #ddd;padding: 6px;border-radius: 3px;" th:src="${d}" alt=""> </a> </div> </div>
th:each="d:${techniqueDisclose.dismantleImgArray}"> <a th:href="${d}"data-size="1040x800" data-med="https://farm4.staticflickr.com/3894/15008518202_b016d7d289_b.jpg" data-med-size="824x600" data-author="Folkert Gorter" class="demo-gallery__img--main"> <img width="120" style="margin: 10px 0;background-color: #ddd;padding: 6px;border-radius: 3px;" th:src="${d}" alt=""> </a> </div> </div> -
<span style="color:#333333"> </span>
th:selected
<div class="form-group">
<label>年龄</label> <select class="form-control" id="age">
<option value="1" th:selected="${sex=='1'}">男</option>
<option value="2" th:selected="${sex=='2'}">女</option>
</select></div>
https://www.cnblogs.com/nuoyiamy/p/5591559.html 基本语法链接