i have list of task in my database. i want to filter by date(completed date) how to pass date with $http get request.i tried some code.it is giving exception. can any one help me.
angular:
$scope.date=1468175400000;
var deadline = new Date($scope.date);
$http.get(
'/user/task/gettasks/?status=' + $scope.status
+ '&priority=' + $scope.priority
+ '&projectId=' + $scope.project+'&deadline='+deadline).success(
function(response) {
debugger
$scope.tasks = response;
}).error(function(error) {
console.log(error)
})
service(spring):
@RequestMapping("/gettasks")
@JsonView({ TaskJsonView.Summary.class })
public List<Task> getTasks(@RequestParam(value="status" ) String status,
@RequestParam("priority") String priority,
@RequestParam("projectId") String projectId,@RequestParam("deadline") Long deadline) {
System.out.println(deadline);
return taskControllerService.getTasks(status, priority, projectId,deadline);
}
error:
Object {
timestamp: 1468819101831,
status: 400,
error: "Bad Request",
exception: "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException",
message: "Failed to convert value of type [java.lang.String]… "
MonJul11201600: 00: 00 GMT0530(IndiaStandardTime)
""…
}
error: "Bad Request"
exception: "org.springframework.web.method.annotation.MethodArgumentTypeMismatchException"
message: "Failed to convert value of type [java.lang.String] to required type [java.lang.Long]; nested exception is java.lang.NumberFormatException: For input string: "
MonJul11201600: 00: 00 GMT0530(IndiaStandardTime)
""
path: "/user/task/gettasks/"
status: 400 timestamp: 1468819101831 proto: Object
For deadline you are passing a date object.
Pass this instead new Date($scope.date).getTime() this will send the deadline as long timestamp.
var deadline = new Date($scope.date).getTime();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With