Search code examples
apachejquerytomcatmod-proxy

Apache multipart request mod_proxy


I have jquery ajax request routed like this

  var data = new FormData();
  data.append('payload1',payload);
  data.append('attachment',attchmentPlayLoad);
  data.append("fileData" + i , file);

    // Do post
    $.ajax({
        url : attchmentUrl,
        method : "POST",
        data : data,
        cache: false,
        processData: false,
        contentType:false
    }).success(function(data, status, headers, config){

  alert("success");         

    }).error(function (data, status, headers, config){
        alert("ERROR!");

    });

And my code mod proxy looks like this

<IfModule proxy_module>
    ProxyPass /some/service  http://<my-host>/webapp/service
</IfModule>

The question is, if i do a post above request, to the spring controller like this

@RequestMapping(value = "/multipartForm/receive", method = RequestMethod.POST)
    public @ResponseBody JsonResponse upload(@RequestParam("playload") String something,@RequestParam("attachment") String attachments,MultipartHttpServletRequest request) {
   //do some processing
}

Ajax Post gets converted to GET, which is the first problem and how to correctly setup modproxy cofigure ajax multipart requests?

Without the apache, sending requests directly to tomcat seems to work ok.

Thanks for the help in advance


Solution

  • Perhaps your call to ajax is wrong...? According to the docs it should be type:"POST" rather than method:"POST":

    http://api.jquery.com/jQuery.ajax/