蹉跎了n天,终于发现了问题的所在。我的症状是第二个页面在验证出错后再次提交则返回首页,form丢失,就那么几行代码,愣是瞪了这么些天,找资料,可能没搜到点子上,也没多大收获,下午偶然想到换个关键词搜搜,结果看到类似问题,试验,解决。referenceData中不要用getCommand(request)获取已经存到session中的表单对象,实在想获取,用下面这段:
HttpSession session=request.getSession(false);
if(session==null)
{
throw new ServletException(
"Must have session when trying to bind (in session-form mode)");
}
String formAttrName=getFormSessionAttributeName(request);
Object sessionFormObject=session.getAttribute(formAttrName);
if(sessionFormObject==null)
{
throw new ServletException(
"Form object not found in session (in session-form mode)");
}
return sessionFormObject;
参考:http://forum.springframework.org/archive/index.php/t-20408.html