0
我的春天控制器發送對象「部門」和我的表格得到它 ,並需要檢查員工檢查多少部門的工作由各部門檢查 保存工程偉大但當用戶編輯員工他需要查看已經檢查過的工作。百里香屬性檢查包含其他屬性值
使它工作我需要使它像︰th:checked =「$ {jobs.contains($ {job.id})}」 但我想我不能把屬性值放在其他屬性值。
<div th:each="job : ${department.jobList}" class="col-md-4">
<fieldset class="form-group">
<label class="custom-control custom-checkbox">
<input name="jobs" th:checked="${jobs.contains(34L)}" th:value="${job.id}" type="checkbox" class="custom-control-input"/>
<span th:text="${job.name}" class="custom-control-description"></span>
<span class="custom-control-indicator"></span>
</label>
</fieldset>
</div>
我的控制器:
// Edit employee page
@RequestMapping("/panel/{workPlaceName}/employees/{id}")
public String editEmployeesPage(Model model, HttpSession httpSession, HttpServletRequest request,@PathVariable Long id) {
// Auto login check
WorkPlace workPlace = new WorkPlace();
Employee employee = new Employee();
Object logInTemp = httpSession.getAttribute ("loggedInUser");
if (logInTemp != null){
Object tempLogIn = httpSession.getAttribute ("loggedInUser");
LogIn logIn = (LogIn) tempLogIn;
workPlace = workPlaceService.findById(logIn.getUserName());
model.addAttribute("workPlace",workPlace);
employee = employeeService.findById(id);
if(!model.containsAttribute("employee")) {
model.addAttribute("employee", employee);
}
} else {
return "redirect:/";
}
// END of Auto login check
ArrayList<Long> jobs = new ArrayList<>();
for (int i = 0; i < employee.getJobList().size(); i++) {
jobs.add(employee.getJobList().get(i).getId());
}
model.addAttribute("jobs", jobs);
model.addAttribute("action","/panel/"+workPlace.getName()+"/employees/"+employee.getId());
return "workplace/editEmployee";
}