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