我正在使用 Spring 3.1.0.RELEASE。出于某种原因,在我的控制器中,当我发布表单并在发生错误时返回原始屏幕时,模型属性不会像我通过 GET 方法调用页面时那样填充。在我的控制器中,我有
@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");
}
我做错了什么,我该如何纠正?