title: Getting 404 while sending data from controller.js to spring controller
body: <p>I have to send id to spring controller but I am getting 404. I am using angularjs, spring and mongodb.I am getting data perfectly. Onclick of approve/reject button id is being passed to controller.js but after that I am getting 404. </p>
  
  <p>Also I have to pass index of row to controller so that i can remove row once data is updated in database. How to do this? Please provide some logic.</p>
  
  <p><strong>Html</strong></p>
  
  <pre><code>&lt;tbody&gt;
    &lt;tr ng-repeat="task in taskDetails"&gt;
      &lt;td style="text-align: center;"&gt;{{task.name}}&lt;/td&gt;
      &lt;!-- &lt;td style="text-align: center;"&gt;{{task.owners}}&lt;/td&gt; --&gt;
      &lt;td style="text-align: center;"&gt;
        &lt;span ng-repeat="owner in task.owners"&gt;{{owner.ownerName.name}}{{$last ? '' : ', '}}&lt;/span&gt;
      &lt;/td&gt;
      &lt;td  style="text-align:center;"&gt;
        &lt;button class="btn btn-mini btn-primary" ng-click="approveTask(task)" value="approveTask"&gt;Approve&lt;/button&gt;
        &lt;button class="btn btn-mini btn-danger" ng-click="rejectTask(task)" value="rejectTask"&gt;Reject&lt;/button&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>//controller.js
  $scope.approveTask = function(task) {
      alert(task);
      var dataObj = {
          id : task.id
      };
      $http.post('/userNotification/task/approve', dataObj).success(function (data) {   
          alert("Approved! "+ data);
      });
  }
  
  $scope.rejectTask = function(task) {
      alert(task);
      var dataObj = {
          id : task.id
      };
      $http.post('/userNotification/task/reject'+ dataObj).success(function(data) {
          alert("Rejected! "+ data);
      });
  }
  </code></pre>
  
  <p><strong>Spring Controller</strong></p>
  
  <pre><code>//spring controller
  
  package com.rmtool.controller;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  import com.rmtool.mongo.dao.TaskDAO;
  import com.rmtool.service.MongoService;
  
  @Controller
  @RequestMapping("/userNotification")
  public class UserNotificationController {
  
    @Autowired
    MongoService mongoService;
  
    @RequestMapping(value = "/fetchTaskForApproval",
                    method =  RequestMethod.GET)
    public @ResponseBody List&lt;TaskDAO&gt; notification(){
      System.out.println("entering notification");
      List&lt;TaskDAO&gt; taskDAOLists=new ArrayList&lt;TaskDAO&gt;();
      taskDAOLists = mongoService.fetchPendingTask("Pending Approval");
      System.out.println("exiting notification");
      System.out.println(taskDAOLists);
      return taskDAOLists;
    }
  
    @RequestMapping(value = "/task/approve", method = RequestMethod.POST)
    public @ResponseBody void approveTask(@RequestBody TaskDAO task){
      System.out.println("task Id :"+task.getId());
      mongoService.approvePendingTask(task.getId());
    }
  
    @RequestMapping(value = "/task/reject/{id}", method = RequestMethod.POST)
    public @ResponseBody void rejectTask(@PathVariable("id") String id){
      mongoService.rejectPendingTask(id);
    }
  }
  </code></pre>