0
我發現從春季論壇上的代碼,這似乎是實現在Spring 3 wizardForms一種有趣的方式:WizardForm在春季3
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processSubmit(
@ModelAttribute("pet") Pet pet,
SessionStatus status) {
if (pet.getFieldOne() == null) {
//return the form that will set field one's value
return new ModelAndView(...);
} else if (pet.getFieldTwo() == null) {
//return the form that will set field two's value
return new ModelAndView(...);
} //and so on for all the other field that need to be set...
...
else {
//once the object has all necessary fields
//set and validated, then do what needs
//to be done to finish. Store object, end
//session, and return your success view.
this.clinic.storePet(pet);
status.setComplete();
return new ModelAndView(...);
}
}
誰能告訴我什麼這裏的存儲單元中,這是一個很好的辦法?
但是,如果我爲第一個表單頁面創建模型屬性對象,它如何爲空? – mjgirl 2011-02-01 09:59:37