我有几个复选框,我如何在控制器中获得它们的参数?我试着在控制器里写点东西,但是不起作用
my html.
<input type="checkbox" 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("formFrequencylist")List <FormFrequency> formFrequencylist) {
FormHasFrequency formHasFrequency=new FormHasFrequency();
atiServiceImpl.saveRegulatoryForm(regulatoryform);
acthasform.setFormId(regulatoryform);
atiServiceImpl.saveActHasForm(acthasform);
for (FormFrequency form:formFrequencylist) {
formHasFrequency.setFormId(regulatoryform);
formHasFrequency.setFrequencyId(form);
atiServiceImpl.saveFormHasFrequency(formHasFrequency);
}
return "redirect:/regulatoryform/";
}
1条答案
按热度按时间2vuwiymt1#
我已经解决了我的问题
还有我的控制器