我使用Spring 3.1.0.RELEASE。出於某種原因,在我的控制器中,當我POST表單並在發生錯誤時返回原始屏幕時,模型屬性沒有像我通過GET方法調用頁面時那樣獲得填充。在我的控制器中我有爲什麼我的Spring模型不能使用正確的屬性填充?
@Controller
public class StandardsUploadController {
…
@RequestMapping(value = "/upload")
public String getUploadForm(Model model) {
model.addAttribute(new StandardsUploadItem());
model.addAttribute("gradeList", gradeList);
model.addAttribute("subjectList", subjectList);
return "upload/index";
}
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public ModelAndView processFile(final StandardsUploadItem uploadItem,
final BindingResult result,
final HttpServletRequest request,
final HttpServletResponse response) throws InvalidFormatException, CreateException, NamingException {
stdsUploadValidator.validate(uploadItem, result);
if (!result.hasErrors()) {
try {
…
} catch (IOException e) {
LOG.error(e.getMessage(), e);
e.printStackTrace();
}
} // if
return new ModelAndView("upload/index");
}
我在做什麼錯,我該如何糾正它?