我在休息架构中使用spring boot。我使用jquery来调用服务器URL。
@PatchMapping(value = "/members/{memberId}/payments/{paymentsId}")
public boolean updatePaymentStatus(@PathVariable("memberId") Long memberId, @PathVariable("paymentsId") List<Long> paymentsId, @RequestParam("status") StatusEnum status) {
if (status == StatusEnum.CANCEL) {
paymentService.cancelPayments(paymentsId);
} else if (status == StatusEnum.REFUND) {
paymentService.refundPayments(memberId, paymentsId);
}
return true;
}
在客户端,我尝试使用此代码调用此URL
function paymentStatusAjaxCall(paymentsId, status) {
debugger;
var memberId = $('#memberId').val();
var type = "patch";
var url = getHostName() + "/members/" + memberId + "/payments/" + paymentsId;
jQuery.ajax({
type: type,
url: url,
data: {"status": status},
contentType: "application/json",
dataType: 'json',
headers: {
"Authorization": "Basic " + $.cookie('authorization')
},
success: function (data, status, jqXHR) {
var deferredPayment = loadMemberPaymentTable(templateMemberPayment, memberId);
$.when(deferredPayment).then(function () {
$("[data-localize]").localize("norc", {language: "fr", pathPrefix: "locales"});
});
},
error: function (jqXHR, status) {
checkError(jqXHR);
}
});
}
url的例子
http://localhost:8080/members/1/payments/9,1
服务器网址永远不会加入,在客户端我得到404
如果我这样做
http://localhost:8080/members/1/payments/9,1?status=CANCEL
那项工作