我有問題,@ModelAttribute
,Spring MVC的對象爲空
CustEntity
有像「姓名」等對象也有稱爲bankAcc的BankAccEntity
列表,它具有編號和名稱。
在GET方法當我使用getBankAcc()
我CUST具有bankaccounts ArrayList中,但是當我從GET到POST通過對象「顧客」,他有[]中BankAcc
列表;/
我的代碼片段是以下:
@RequestMapping(value = "/aaa.html", method = RequestMethod.GET)
public String aaaGet(Model m, Principal principal) {
...
CustEntity cust = custService.getCustByUserName(principal);
cust.getBankAcc();
m.addAttribute("customer", cust);
...
}
@RequestMapping(value = "/aaa.html", method = RequestMethod.POST)
public String aaaPost(
@ModelAttribute("customer") CustomerEntity cust,
BindingResult results, RedirectAttributes redirectAttributes,
Model m) {
cust.getBankAcc();
...
}
問候, swierzy