title: how to pass JSON object as a PathVariable to spring controller
body: <p>I am working on spring application with angularjs. I want to pass the JSON object as a <code>@PathVariable</code> to the spring controller, but with my below code, when passing the JSON object as a PathVariable it is not hitting the spring controller, and it is not showing any error too.Any inputs?</p>
  
  <p>sample code:
  js:</p>
  
  <pre><code>myApp.controller('passJSONTestController', function ($rootScope, $scope, MyService) {
       $scope.submitdata=function(){
          $scope.myJSONData = [
              {   'name':$scope.name,
                  'sinNumber': $scope.sinNo,
                  'status': $scope.status,
                  'message':$scope.message,
              }
          ];
          var fd=new FormData();
          angular.forEach($scope.files,function(file){
              console.log("file " + file);
              fd.append('file',file);
          });
          MyService.sendJSON($scope.myJSONData,fd).then(
              function (response) {
                  //
              },
              function (errResponse) {
               }
          );
      }
  });
  </code></pre>
  
  <p>MyService.js</p>
  
  <pre><code>myService.sendJSON = function (myJSONData,fd) {
           var deferred = $q.defer();
          var myUrl = applnURL + '/dataStack/' + myJSONData + '/getAllDataInfo.form';
            var config = {
              transformRequest: angular.identity,
               headers : {
                  'Content-Type': undefined
              }
          }
           $http.post(repUrl, fd, config ).then(function (response) {
          }, function (response) {
           });
           return deferred.promise;
       }
  </code></pre>
  
  <p>spring controller:</p>
  
  <pre><code>@Controller
  @RequestMapping("/dataStack")
  public class GetData {
   @RequestMapping(value = "/{myJSONData}/getAllDataInfo", method = RequestMethod.POST)
      public
      @ResponseBody
      String sendInfo(@RequestParam("file") List&lt;MultipartFile&gt; multiPartFileList,@PathVariable("myJSONData") List&lt;MyDTO&gt; myDTO){                          
          System.out.println("In Spring controller");
     }
  </code></pre>
  
  <p>Why is the request passed not hitting the spring controller?
  PS: If i remove the pathvariable in spring controller and remove it from mySerivce.js, then it is hitting the spring controller. </p>
  
  <p>-------------EDITED (Updated code)--------------
  I have added the below class:</p>
  
  <pre><code>@Configuration
  public class MultiFileResolverConfig {
      @Bean(name = "multipartResolver")
      public MultipartResolver multipartResolver() {
          System.out.println("--In configuration file multipartResolver--");
          return new CommonsMultipartResolver();
      }
  }
  </code></pre>
  
  <p>spring-servlet.xml
  I have added below <code>&lt;bean&gt;</code> in sprig-servlet.xml configuration file</p>
  
  <pre><code>&lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&gt;
      &lt;property name="maxUploadSize" value="10000000"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>html code:</p>
  
  <pre><code>&lt;html&gt;
  ..elements for name,sinNumber,status,message
    &lt;input type = "file"  name="file" file-model="file" multiple/&gt;
  ..//submit button
  &lt;/html&gt;
  </code></pre>
  
  <p>js code:</p>
  
  <pre><code> myApp.directive('fileModel', ['$parse', function ($parse) {
      return {
          restrict: 'A',
          link: function(scope, element, attrs) {
              var model = $parse(attrs.fileModel);
              var modelSetter = model.assign;
  
              element.bind('change', function(){
                  scope.$apply(function(){
                      modelSetter(scope, element[0].files[0]);
                  });
              });
          }
      };
  }]);
  
      myApp.controller('passJSONTestController', function ($rootScope, $scope, MyService) {
           $scope.submitdata=function(){
              $scope.myJSONData = [
                  {   'name':$scope.name,
                      'sinNumber': $scope.sinNo,
                      'status': $scope.status,
                      'message':$scope.message,
                  }
              ];
              var fd=new FormData();
              angular.forEach($scope.files,function(file){
                  console.log("file " + file);
                  fd.append('file',file);
              });
              fd.append("json",$scope.myJSONData);
              MyService.sendJSON(fd).then(
                  function (response) {
                      //
                  },
                  function (errResponse) {
                   }
              );
          }
      });
  </code></pre>
  
  <p>service.js</p>
  
  <pre><code>myService.sendJSON = function (fd) {
           var deferred = $q.defer();
          var myUrl = applnURL + '/dataStack/getAllDataInfo.form';
            var config = {
              transformRequest: angular.identity,
               headers : {
                  'Content-Type': undefined
              }
          }
           $http.post(myUrl, fd, config ).then(function (response) {
          }, function (response) {
           });
           return deferred.promise;
       }
  </code></pre>
  
  <p>spring controller:</p>
  
  <pre><code>@Controller
  @RequestMapping("/dataStack")
  public class GetDataController{
      @RequestMapping(value = "/getAllDataInfo", method = RequestMethod.POST)
      public @ResponseBody
      String uploadMultipleFileHandler(MultipartHttpServletRequest req) {
  
          System.out.println("in spring upload multiple files");
          List&lt;MultipartFile&gt; multiPartFileList = req.getFiles("file");
          System.out.println("in multiPartFileList " + multiPartFileList.size());//size is always zero
          String[] json = (String[]) req.getParameterMap().get("json");//getting the values submitted
          //code here..
  </code></pre>
  
  <p>I am getting the values for json object but unable to get the files details.
  The size of multiPartFileList.size() is zero.I tried adding only class MultiFileResolverConfig and removing the <code>&lt;bean&gt;</code> declaration in spring-servlet.xml but still the file details is not been passed to the spring controller.</p>