Results 1 to 3 of 3

Thread: simpleformcontroller & modelandview

  1. #1
    Join Date
    Jul 2005
    Posts
    5

    Default simpleformcontroller & modelandview

    the exception info:
    javax.servlet.ServletException: ModelAndView [ModelAndView: materialized View is [null]; model is {command=action.RegisterInfo@1c6572b, 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()
    {
    setCommandClass(RegisterInfo.class);
    }

    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="register.do" method="get">
    Username:<input type="text" name="username" value="" />
    Password:<input type="text" name="password" value="" />
    <input type="submit" value="registe" />
    </form>
    just so simple.but when i use simpleformcontroller,it generate mistake;when i change to the Controller,it is ok.

  2. #2
    Join Date
    Jul 2005
    Posts
    5

    Default

    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. #3
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    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.

Similar Threads

  1. SimpleFormController not do onSubmit
    By heleno_alves in forum Web
    Replies: 2
    Last Post: Oct 18th, 2005, 07:22 AM
  2. RFE? Create fixed ModelAndView in XML
    By wangjammer5 in forum Container
    Replies: 4
    Last Post: Oct 5th, 2005, 09:07 AM
  3. Replies: 1
    Last Post: Aug 26th, 2005, 04:33 AM
  4. Replies: 5
    Last Post: Apr 17th, 2005, 07:16 AM
  5. Servlet & portlet packages (SimpleFormController)
    By mpetrashev in forum Architecture
    Replies: 0
    Last Post: Dec 2nd, 2004, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •