当前位置:网站首页>Thymeleaf data echo, single selection backfill, drop-down backfill, time frame backfill

Thymeleaf data echo, single selection backfill, drop-down backfill, time frame backfill

2022-06-26 04:28:00 good writings make people copy them

Reprint :https://blog.csdn.net/guochanof/article/details/90734174

input backfill

<div class="form-group">
    <label class="col-sm-1 control-label"> Name of customer :</label>
    <div class="col-sm-3">
        <input id="customerName" name="customerName" th:value="${customer.customerName}" class="form-control" type="text">
    </div>
    
</div>


Single choice backfill

<div class="form-group">
    <label class="col-sm-1 col-sm-offset-2 control-label"> Gender  :</label>
    <div class="col-sm-3">
        <label class="radio-inline" th:each="sex:${sexList}">
            <input type="radio" id="sex" name="sex" th:value="${sex.value}" th:text="${sex.name}" th:attr="checked=${customer.sex == sex.value?true:false}" />
        </label>
    </div>
</div>


Time frame backfill

<div class="form-group">
    <label class="col-sm-1 control-label"> Date of birth :</label>
    <div class="col-sm-3">
        <input type="text" class="laydate-icon layer-date form-control" id="birthday" name="birthday" th:value="${customer.birthday}==null?null:${#dates.format(customer.birthday,'yyyy-MM-dd')}" οnclick="laydate({istime: true, format: 'YYYY-MM-DD'})" style="background-color: #fff;" readonly="readonly" />
    </div>
</div>


Pull down backfill

<div class="form-group">
    <label class="col-sm-1 col-sm-offset-2 control-label"> occupation :</label>
    <div class="col-sm-3">
        <select data-placeholder="-- Choose a category --" name="profession" id="profession" class="form-control chosen-select" tabindex="2" required>
            <option value="">-- Choose a category --</option>
            <option th:selected="${customer.profession eq profession.value}" th:each="profession:${professionTypeList}" th:value="${profession.value}" th:text="${profession.name}"></option>
        </select>
    </div>
</div>

Reprint :https://blog.csdn.net/qq_43639296/article/details/88723128

thymeleaf Of textarea For data echo th:text,th:value Cannot echo

 

Nonempty judgment of set

th:if="${not #lists.isEmpty( Custom collection )}"

String splicing

<span th:text="|Welcome to home, ${user.name}!|">
// This is actually equivalent to :
<span th:text="'Welcome to home, ' + ${user.name} + '!'">
// Text substitution can be combined with other types of expressions :
<span th:text="${onevar} + ' ' + |${twovar}, ${threevar}|">

decimal ( rounding )

// Show 1.24
th:text="${#numbers.formatDecimal(1.235, 1, 2)}"

a label - Hyperlinks

// Show 1.24
<a th:href="@{/companyUser/getUserByUserName/(id=${companyUser.id},userName=${companyUser.userName})}">view</a>
<a th:href="@{/companyUser/{companyUser.id}/getUserByUserName>view</a>

Ternary operators judge

th:text="'Execution mode is ' + ( ('0'!='0')? 'Development' : 'Production')"


 

原网站

版权声明
本文为[good writings make people copy them]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180531084835.html