Menu

No method found when submitting form

Help
Lyc1
2007-02-15
2013-04-23
  • Lyc1

    Lyc1 - 2007-02-15

    Hello,

    When I try to submit a form build with Springlayout, I have to following error :

    net.sf.springlayout.web.controller.NoSuchControllerMethodException: No public method in controller with name 'No Method Specified' in class 'eu.b2i.telematic.rus.server.presentation.controller.TestController'
        at net.sf.springlayout.web.controller.AbstractBaseFormController.onSubmit(AbstractBaseFormController.java:282)
        at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
        at net.sf.springlayout.web.controller.AbstractBaseFormController.processFormSubmission(AbstractBaseFormController.java:1038)
        at net.sf.springlayout.web.controller.AbstractBaseFormController.handleRequestInternal(AbstractBaseFormController.java:545)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:820)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:755)
    ...

    It seems that the "method" parameter is not found. But if I check HTTP request sent to the server, I can see that :

    ...
    Content-Type: multipart/form-data; boundary=---------------------------4122892432213
    Content-Length: 1705
    -----------------------------4122892432213
    Content-Disposition: form-data; name="e"

    1
    ...
    -----------------------------4122892432213
    Content-Disposition: form-data; name="method"

    save
    -----------------------------4122892432213--

    I don't think that this notation can be considered as HTTP parameter declaration.

    So what's wrong with my configuration ?

    Thanks

     
    • adam

      adam - 2007-02-17

      Hi Damien,

      When submitting a form using SpringLayout you need to have a parameter named 'method' in the parameter map. The value of this parameter is the name of the method in your controller which will be called. For instance if the value 'modify' is given, the method:

      public ModelAndView modify(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception
         {
          ...
         }

      needs to exist in your controller and will be called on post. SpringLayout provides a convenience javascript method:
      performAction(formName, methodName); which will create the parameter 'method' and populate it with the value provided in methodName and post the form.

       
      • Lyc1

        Lyc1 - 2007-02-19

        I found the problem.

        I did a test thanks to theses examples :
        http://springlayout.svn.sourceforge.net/viewvc/springlayout/trunk/src/main/webapp/test.jsp?revision=20&view=markup

        The form is configured with enctype="multipart/form-data", which can't work in the controller (request.getParameter("method") doesn't work form multipart form)

        I think something else must be configured in my bean to handle multipart form request. Anyway, it works as-is with classical form.

         
        • adam

          adam - 2007-02-19

          I think you might find that this isn't the problem. I have a number of controller examples where the form is using enctype="multipart/form-data" and they work correctly, the method parameter is recovered just fine.

          Do you have a MultipartReslover configured?

           
          • Lyc1

            Lyc1 - 2007-02-19

            Ok,I understand now.
            MultipartResolver was a part of Spring that I didn't know.

            It works as expected know.

            That's for your help

             

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.