我的Angularjs工厂要求如下:
.factory('TrackingNumberDetailsUpsGeneralService', function ($http) {
return {
findByInvoiceDetailsId: function (invoiceDetails) {
console.log("invoiceDetails " + invoiceDetails.id);
return $http.get('/api/trackingNumberDetailsUpss/byInvoiceDetailsId', {params: {invoiceDetailsId : invoiceDetails.id}}).then(function (response) {
return response.data;
});
}
};
});
在我的 Tracking...Resource.java 中,我有
@RequestMapping(value = "/trackingNumberDetailsUpss/byInvoiceDetailsId/",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public List<TrackingNumberDetailsUps> findByInvoiceDetailsId(@RequestParam(value="invoiceDetailsId") Long invoiceDetailsId,
@RequestParam(value = "page" , required = false) Integer offset,
@RequestParam(value = "per_page", required = false) Integer limit) {
log.debug("REST request to get TrackingNumberDetailsUps By Invoice Details Id " + invoiceDetailsId);
return trackingNumberDetailsUpsService.findByInvoiceDetailsId(invoiceDetailsId);
}
但我收到以下错误:
http://localhost:8080/api/trackingNumberDetailsUpss/byInvoiceDetailsId?cacheBuster=1444014377012&invoiceDetailsId=2 400 Bad Request
{"timestamp":1444015194707,"status":400,"error":"Bad Request","exception":"org.springframework.beans
.TypeMismatchException","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: \"byInvoiceDetailsId
\"","path":"/api/trackingNumberDetailsUpss/byInvoiceDetailsId"}
我无法弄清楚问题出在哪里。任何人都可以帮助我解决这个问题。
以下是我的请求:
.factory('TrackingNumberDetailsUpsGeneralService', function ($http) {
return {
findByInvoiceDetailsId: function (invoiceDetails) {
console.log("invoiceDetails " + invoiceDetails.id);
return $http.get('/api/trackingNumberDetailsUpss/byInvoiceDetailsId', {params: {invoiceDetailsId : invoiceDetails.id}}).then(function (response) {
return response.data;
});
}
};
});