Thymeleaf在前台下拉列表获取后台传的值

                                                                                                                     Thymeleaf在前台下拉列表获取后台传的值

后台添加代码:

/**
     * 新增机构
     */
    @GetMapping("/add")
    public String add(ModelMap mmap)
    {
        List<Scholar>  scholars = scholarService.selectScholarListName();
        mmap.put("scholars",scholars);
        return "module/institution/add";
    }
    

后台修改代码:

 

/**
     * 修改机构
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        Institution institution = institutionService.selectInstitutionById(id);
        List<Scholar>  scholars = scholarService.selectScholarListName();
        mmap.put("scholars",scholars);
        mmap.put("institution", institution);
        return  "module/institution/edit";
    }

 

 

 

前台代码添加:

<div class="form-group">    
                <label class="col-sm-3 control-label">主要研究人员:</label>
                <div class="col-sm-8" >
                    <!--<input id="majorResearcher" name="majorResearcher" class="form-control" type="hidden">-->
                        <!--<select name="title"  id="title" class="form-control m-b">
                            <option th:each="scholars : ${scholars.title}" th:text="${scholars.title}" th:value="${scholars.title}" ></option>
                        </select>-->
                    <select class="form-control" name="majorResearcher">
                        <option value="">  --  主要研究人员 --  </option>
                        <option th:each="scholars:${scholars}" th:value="${scholars.title}" th:text="${scholars.title}"></option>
                    </select>

                </div>
            </div>

 

前台代码回显:

<div class="form-group">    
                <label class="col-sm-3 control-label">主要研究人员:</label>
                <div class="col-sm-8">
                   <!-- <input id="majorResearcher" name="majorResearcher" th:field="*{majorResearcher}" class="form-control" type="text" >-->
                    <select class="form-control" name="majorResearcher">
                        <option  value="">  --  主要研究人员 --  </option>
                        <option th:each="scholars:${scholars}" th:value="${scholars.title}" th:text="${scholars.title}" th:field="*{majorResearcher}"></option>
                    </select>
                </div>
            </div>

前台页面添加效果:

前台页面回显效果:


前台页面的效果:

转载于:https://www.cnblogs.com/zhukaixin/p/10488763.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值