Мой html
<input type="checkbox" th:name="formFrequencylist" th:each="formfrequencylist : ${formfrequencylist}" th:value="${formfrequencylist.id}" th:text="${formfrequencylist.frequencyNm}"
th:field="${formFrequency.id}" >
Мой Контроллер
@PreAuthorize("hasRole('ROLE_ADMIN')")
@GetMapping( value = "create/")
public String create( Model model) {
RegulatoryForm regulatoryform=new RegulatoryForm();
ActHasForm acthasform=new ActHasForm();
FormFrequency formFrequency = new FormFrequency();
List<RegulatoryAct> actlist=atiServiceImpl.findAllRegulatoryAct();
List<FormFrequency> formfrequencylist=atiServiceImpl.findAllFormFrequency();
model.addAttribute("actlist",actlist);
model.addAttribute("regulatoryform",regulatoryform);
model.addAttribute("acthasform",acthasform);
model.addAttribute("formFrequency",formFrequency);
model.addAttribute("formfrequencylist",formfrequencylist);
return "regulatoryform/create";
}
@PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping(value = "create/")
public String create(@ModelAttribute("regulatoryform") RegulatoryForm regulatoryform,@ModelAttribute("acthasform")ActHasForm acthasform,@ModelAttribute(name="formFrequencylist")HashSet <String> formFrequencylist) {
FormHasFrequency formHasFrequency=new FormHasFrequency();
FormFrequency formFrequency=new FormFrequency();
atiServiceImpl.saveRegulatoryForm(regulatoryform);
acthasform.setFormId(regulatoryform);
atiServiceImpl.saveActHasForm(acthasform);
System.out.println("hello1");
for (String form:formFrequencylist) {
System.out.println("hello2");
formHasFrequency.setFormId(regulatoryform);
int idform = Integer.parseInt(form);
formFrequency.setId(idform);
formHasFrequency.setFrequencyId(formFrequency);
atiServiceImpl.saveFormHasFrequency(formHasFrequency);
}
return "redirect:/regulatoryform/";
}
То что я сейчас сделала не работает, не заходит даже в цикл for, подскажите как правильно нужно получать эти значения из checkbox?