我正在使用spring boot,spring v4.2.5
我正在尝试传递一个很长的列表。
我的控制器是:
@RequestMapping(value = "/rest/members/{memberId}/payments/{paymentsId}/process/{paymentMode}", method = RequestMethod.PUT)
public void processPayment(@PathVariable("memberId") Long memberId, @PathVariable("paymentsId") List<Long> paymentsId, @PathVariable("paymentMode") PaymentModeEnum paymentMode) {
paymentService.processPayment(paymentsId, paymentMode);
}
使用此链接永远不会调用Controller。
http://localhost:8080/rest/members/6/payments/105,106/process/ATM
但它与此相关
http://localhost:8080/rest/members/6/payments/105/process/ATM
是否可以传递长列表?
答案 0 :(得分:0)
使用long数组而不是列表,如果需要,只需将其转换为列表。
@RequestMapping(value = "/rest/members/{memberId}/payments/{paymentsId}/process/{paymentMode}", method = RequestMethod.PUT)
public void processPayment(@PathVariable("memberId") Long memberId, @PathVariable("paymentsId") Long[] paymentsId, @PathVariable("paymentMode") PaymentModeEnum paymentMode) {
paymentService.processPayment(Arrays.asList(paymentsId), paymentMode);
}