前端页面
<div class="form-group">
<label class="col-sm-3 control-label">所属公司:</label>
<div class="col-sm-8">
<select id="company" class="form-control select2-multiple">
<option th:each="comp:${companys}" th:value="${comp.Id}" th:text="${comp.companyName}" th:selected="${comp.companyName eq companyName}"></option>
</select>
</div>
</div>
后端
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
SysCustomer sysCustomer = sysCustomerService.selectSysCustomerById(id);
mmap.put("sysCustomer", sysCustomer);
SysCompany sysCompany=new SysCompany();
mmap.put("companyName",sysCustomer.getCompany().getCompanyName());
mmap.put("companys",sysCompanyService.selectSysCompanyList(sysCompany));
return prefix + "/edit";
}