zoukankan      html  css  js  c++  java
  • java学习day46-Thymeleaf数据回显

    Thymeleaf数据回显

    input回填

    <div class="form-group">
        <label class="col-sm-1 control-label">用户名:</label>
        <div class="col-sm-3">
            <input id="username" name="username" th:value="${user.username}" class="form-control" type="text">
        </div>  
    </div>
    

    单选回填

    <div class="form-group">
        <label class="col-sm-1 col-sm-offset-2 control-label">性别 :</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=${user.sex == sex.value?true:false}" />
            </label>
        </div>
    </div>
    

    时间框回填

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

    下拉回填

    <div class="form-group">
        <label class="col-sm-1 col-sm-offset-2 control-label">职业:</label>
        <div class="col-sm-3">
            <select data-placeholder="--选择类别--" name="profession" id="profession" class="form-control chosen-select" tabindex="2" required>
                <option value="">--选择类别--</option>
                <option th:selected="${user.profession eq profession.value}" th:each="profession:${professionTypeList}" th:value="${profession.value}" th:text="${profession.name}"></option>
            </select>
        </div>
    </div>
    

    textarea数据回显

    thymeleaf的textarea数据回显用th:text,th:value不能回显

    集合的非空判断

    th:if="${not #lists.isEmpty(自定义集合)}"
    

    字符串拼接

    <span th:text="|Welcome to HeBei, ${user.name}!|">
    //这实际上相当于:
    <span th:text="'Welcome to HeBei, ' + ${user.name} + '!'">
    //文字替换可以与其他类型的表达相结合:
    <span th:text="${onevar} + ' ' + |${twovar}, ${threevar}|">
    

    小数(四舍五入)

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

    a标签-超链接

    <a th:href="@{/user/doUpdate/(id=${companyUser.id},username=${user.username})}">view</a>
    <a th:href="@{/user/{user.id}/getUserByUserName>view</a>
    

    三元运算符判断

    th:text="'Execution mode is ' + ( ('0'!='0')? 'Development' : 'Production')"
    
  • 相关阅读:
    ERROR: Cannot set priority of registrydns process 33740
    Hbase和Phoenix部署-单机版
    ambari安装hdp时,新建的ambari-hdp-1.repo中baseurl无值
    centos7.2升级openssh到8.0
    kafka一个broker挂掉无法写入
    对cdh搭建过程错误总结及解决方法
    streamsets
    [Spark]Task not serializable
    [Kafka]How to Clean Topic data
    Postgresql Master/Slaver
  • 原文地址:https://www.cnblogs.com/liqbk/p/13252066.html
Copyright © 2011-2022 走看看