我使用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");
}
我在做什么错,我该如何纠正它?