Announcement Announcement Module
No announcement yet.
spring 3 REST, HiddenHttpMethodFilter and "multipart/form-data" form bug Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring 3 REST, HiddenHttpMethodFilter and "multipart/form-data" form bug

    Hello all,
    I tried to convert a web app to spring 3 with REST but i got the following problem:

    I have a form with enctype="multipart/form-data", (a form with data and a file) and i want to use put for an update (the restful way) so spring puts a hidden field in the form and the HiddenHttpMethodFilter tries to get the _method hidden field with String paramValue = request.getParameter(this.methodParam);
    to transform the request method to put.

    But for multipart requests the request.getparameter(_method in this case) is always null ! (i guess you have to manually parse the request to get the parameter and the filter doesn't do this not a BUG?)

    so does this mean that it's not possible to use this REST way to process a multipart form?

    thanks in advance for your help...

  • #2
    jira bug

    It seems indeed a missing functionality...

    But is there really not a clean way to solve this issue?



    • #3
      Same here

      Good to see, that I am not the only one experiencing this problem. I described my problem in detail in this thread.
      My workaround was to use POST and different path so it does not confilct with my other post-requestMappings:

      	/* Usually you would use a mapping to HTTP-PUT in a REST-Application.
      	*Since there is a BUG with multipart-requests and HiddenHttpMethodFilter
      	*we use a different path and the POST-Method here
      	@RequestMapping(value="/scriptfile/{id}/update", method = RequestMethod.POST)    
          public String update(@Valid ScriptFile scriptFile,
          							BindingResult result,
          							ModelMap modelMap, HttpServletRequest request) {    
              if (scriptFile == null) throw new IllegalArgumentException("A scriptFile is required");        
              if (result.hasErrors()) {        
                  modelMap.addAttribute("scriptFile", scriptFile);            
                  modelMap.addAttribute("showcases", ShowCase.findAllShowCases());            
                  return "scriptfile/update";            
              setFileParameters(scriptFile, request);
              return "redirect:/scriptfile/" + scriptFile.getId();        
      Last edited by tbender; Feb 24th, 2010, 04:35 AM.