7
結合形式對象我有以下控制器返回視圖:與IDSSpring MVC的思念ID時,從JSP
@RequestMapping(value = "/admin/adminUsers", method = RequestMethod.GET)
public String adminUsers(ModelMap model, HttpSession session) {
Set<TerminalAdmin> users = terminalAdminService.getAllAdmins();
session.setAttribute("users", users);
model.addAttribute("adminRoles", terminalAdminService.findAllAdminRoles());
model.addAttribute("terminalAdmin", new TerminalAdmin());
model.addAttribute("generatedPassword", PasswordUpdateStatus.generatePassword());
return "admin/adminUsers";
}
terminalAdminService.findAllAdminRoles()
回報集合:
JSP的我使其像這樣:
<form:form modelAttribute="terminalAdmin" action="/admin/addNewAdmin">
...
<form:checkboxes items="${adminRoles}" path="adminRoles"/>
...
</form:form>
我有follwing控制器接受此對象:
@RequestMapping(value = "/admin/addNewAdmin")
public String adminUsers(@ModelAttribute @Valid TerminalAdmin terminalAdmin...){
....
}
在調試中,我看到terminalAdmin
帶有沒有ID的adminRoles。
如何解決這一問題?
P.S.
它繼續Dependent collection duplicates when I save entity
你看到的ID在html的jsp頁面? (在下拉菜單中)? –
這個API你用於持久性? JPA? –
@與此問題無關的JPA – gstackoverflow