你的代码是怎么写的?
SimpleFormController 只在下面方法中作了判断:
protected ModelAndView onSubmit(Object command, BindException errors) throws Exception {
ModelAndView mv = onSubmit(command);
if (mv != null) {
// simplest onSubmit version implemented in custom subclass
return mv;
}
else {
// default behavior: render success view
if (getSuccessView() == null) {
throw new ServletException("successView isn't set");
}
return new ModelAndView(getSuccessView(), errors.getModel());
}
}并由
protected ModelAndView onSubmit(
HttpServletRequest request, HttpServletResponse response, Object command, BindException errors)
throws Exception { return onSubmit(command, errors);
}
调用。你覆写任何一个onsubmit()都不会出现你的问题。怀疑你LoginAction中的onsubmit参数和我帖出来那2个方法的不一致.另外,第一个onsubmit()方法明显是为了那种Controller中不含业务逻辑,仅仅只为了转向到某view准备的。

解决方案 »

  1.   

    protected ModelAndView onSubmit
     (Object cmd,BindException ex)throws Exception{
    ModelAndView mav=null;
    LoginInfo logininfo=(LoginInfo)cmd;
    if (login(logininfo)==0){
    HashMap result_hasp=new HashMap();
    result_hasp.put("logininfo", logininfo);
    List msgList=new LinkedList();
    msgList.add("MSG111111");
    msgList.add("MSG222222");
    msgList.add("MSG333333");
    result_hasp.put("messages", msgList);
    mav=new ModelAndView(this.getSuccessView(),result_hasp);
    }else{
    mav=new ModelAndView(this.getFail_view());
    }
    return mav;
    }

    protected ModelAndView onSubmit
    (HttpServletRequest request,HttpServletResponse response,Object cmd,BindException ex)throws Exception{
    ModelAndView mav=null;
    LoginInfo logininfo=(LoginInfo)cmd;
    if (login(logininfo)==0){
    HashMap result_hasp=new HashMap();
    result_hasp.put("logininfo", logininfo);
    List msgList=new LinkedList();
    msgList.add("MSG111111");
    msgList.add("MSG222222");
    msgList.add("MSG333333");
    result_hasp.put("messages", msgList);
    mav=new ModelAndView(this.getSuccessView(),result_hasp);
    }else{
    mav=new ModelAndView(this.getFail_view());
    }
    return mav;
    }