我的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;
});
}
};
});
在我的跟踪... 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;
});
}
};
});
答案 0 :(得分:1)
尝试从/
注释的末尾删除额外的@RequestMapping
。
重要 - 只是经过测试。