Announcement Announcement Module
No announcement yet.
simpleformcontroller & modelandview Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • simpleformcontroller & modelandview

    the exception info:
    javax.servlet.ServletException: ModelAndView [ModelAndView: materialized View is [null]; model is {[email protected], org.springframework.validation.BindException.comma nd=org.springframework.validation.BindException: BindException: 0 errors}] neither contains a view name nor a View object in servlet with name 'spring'

    'spring' is my dispacherservlet name. RegisterInfo is a normal bean,it contains two properties:username and password.
    my controller code:
    public class RegisterAction extends SimpleFormController//implements Controller

    public RegisterAction()

    protected ModelAndView onSubmit(Object cmd,BindException ex)
    return new ModelAndView("RegisterSuccess");
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception
    return new ModelAndView("RegisterSuccess");
    jsp form:
    <form action="" method="get">
    Username:<input type="text" name="username" value="" />
    Password:<input type="text" name="password" value="" />
    <input type="submit" value="registe" />
    just so simple.but when i use simpleformcontroller,it generate mistake;when i change to the Controller,it is ok.

  • #2
    after add the "formView"propertiy of the controller,and click submit button,then will stop at the formView page.
    so i guess,maybe,the mistake happened while convert the httpservletrequest data to the command class.

    but,my bean's properties username and password are String type.i can't catch the reason.

    i didn't know whether i described the problem in detail.3ks


    • #3
      not sure whether this will fix it, but based on your code you shouldn't be overriding onSubmit or handleRequest. If you do, then make sure you are returning the appropriate model, the model you are returning has no command object.

      As to why you are getting a null view? Not sure?

      Basically, set the successView and formView properties of SimpleFormController and it will do the right thing.