thymeleaf 判断select 下拉框 赋值并选中

1546年前 (2020-09-18)SpringBoot6148

下拉框赋值选中:

   <div class="form-group">
                <label class="col-sm-3 control-label">类别:</label>
                <div class="col-sm-8">
                    <select name="category" class="form-control" type="text" id="category" th:field="*{category}">
                        <option th:value="0" >本省</option>
                        <option th:value="1" >省外资源</option>
                    </select>
                </div>
            </div>
            
<div class="col-sm-8">
    <select name="teachpoint" class="form-control m-b" th:with="type=${@dict.getType('teach_point')}">
        <option></option>
        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  ></option>
    </select>
</div>

单选框选中:

  1. <-- aa为值 -->

  2. <input type="radio"  name="aa"  th:value="0" th:checked="${aa==0}"/>显示

  3. <input type="radio"  name="aa"  th:value="1" th:checked="${aa==1 }"/>隐藏

  4. <-- aa为对象属性 -->

  5. <input type="radio"  name="aa"  th:value="0" th:field="*{aa}"/>显示

  6. <input type="radio"  name="aa"  th:value="1" th:field="*{aa}"/>隐藏

本文原创,转载必追究版权。

分享给朋友:

相关文章

每次开机checking file system on d

 解决方案:点击左下角(开始)- (运行)输入(CMD)回车 - 进入CMD界面- 输入(d:)回车 - 输入(chkdsk /f)中间有空格。回车,出现提示按Y键,完成后,重启一次会检...

jquery 操作html元素(及CSS)

jquery 操作html元素(及CSS)

 $("li").addClass("aui-user-view-cell aui-img") ;  //给元素添加样式$('#a1...

MyEclipse 中项目修改SVN的地址

MyEclipse 中项目修改SVN的地址

在工作环境调整时,有的时候SVN服务器的地址需要修改,而正在开发中的项目在Eclipse中有些代码没有提交,此时怎么修改SVN的地址呢?以下有一个简单的办法:一、在MyEclipse中选择Window...

office 2010安装、激活、激活工具下载

office 2010安装、激活、激活工具下载

 首先下载好工具包(包括office 2010安装程序、激活工具及Microsoft .NET Framework 4.0),点击工具包下载进行下载;安装好office 2010。如果是wi...

Java判断是数字还是字符串

方法一:利用正则表达式public class Testone {public static void main(String[] ...

如果有人夸你漂亮,你会如何回复

如果有人夸你漂亮,你会如何回复

       因为长得好看,会经常被别人夸长得漂亮,该如何机智而又优雅的回复,才能表达出谦虚而又不失敷衍的??如果是对方谦虚:谢谢,你也很漂...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。