小白刚开始学,用别的大佬的代码想在此基础上改一下
想把url后面再加一个参数 然后通过ajax把这个参数传到后台
当前的url长这样:
ajax长这样:
function pay() {
$.ajax({
url: "${pageContext.request.contextPath}/order/pay/${requestScope.productOrder.productOrder_code}",
type: "PUT",
data: null,
dataType: "json",
success: function (data) {
if (data.success !== true) {
alert("订单处理异常,请稍候再试!");
}
location.href = "/tmall" + data.url;
},
beforeSend: function () {
},
error: function () {
alert("订单支付出现问题,请重新支付!");
location.href = "/tmall/order/0/10";
}
});
}
后台长这样:
@RequestMapping(value = "order/pay/{order_code}", method = RequestMethod.GET)
public String goToOrderPayPage(Map<String, Object> map, HttpSession session,
@PathVariable("order_code") String order_code
) {
想要多加一个参数,单独测试可以取到值:
${requestScope.productOrder.productOrderItemList[0].productOrderItem_number}
把它加到了ajax后面:
function pay() {
$.ajax({
url: "${pageContext.request.contextPath}/order/pay/${requestScope.productOrder.productOrder_code}/${requestScope.productOrder.productOrderItemList[0].productOrderItem_number}",
type: "PUT",
data: null,
dataType: "json",
success: function (data) {
if (data.success !== true
值取到了
后台不知道怎么加 随便写了一个:
@RequestMapping(value = "order/pay/{order_code}/{order_number}", method = RequestMethod.GET)
public String goToOrderPayPage(Map<String, Object> map, HttpSession session,
@PathVariable("order_code") String order_code,
@PathVariable("order_number") String order_number
) {
然后就报错了: