为了账号安全,请及时绑定邮箱和手机立即绑定

我写一个给前台的删除的接口可是报五百的错误说不支持get请求方式怎么处理呢?又打很知道吗

我写一个给前台的删除的接口可是报五百的错误说不支持get请求方式怎么处理呢?又打很知道吗

鬼鬼qiang 2017-09-25 21:11:44
@DeleteMapping("/del/{id}")void del(@PathVariable int id){    orderRepository.delete(id);}++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++前台+++++++++++++++++++++++++++++++++++++++++++++++++++++++++function showOrder(userid){ $(".order-info").html("<img class='loadgif' src='images/loading.gif'/>"); $.ajax({ url:"http://127.0.0.1:8081/order/list/" + userid,  type:"get", success:function(data){ console.info("订单信息",data); var orderHtml = ""; $.each(data, function(index,order) { var productHtml = ""; $.each(order.plist, function(i,product) { productHtml += "<tr><td><a href='##'><img src="  + product.img + " alt='product'></a></td><td style='max-width: 200px;'><span>" + product.name + " </span></td><td>¥ " + product.sell  + " </td><td><span>数量: " + order.nlist[i] + " </span></td></tr> " }); orderHtml += "<div class='order-detail' data-no='" + order.orderNo + "' data-username='" + order.user.username + "' data-day='" + order.createDate + "'><div class='order-top'><strong>订单号:</strong><span>" + order.orderNo + "</span><strong>购买者:</strong><span>" + order.user.username  + "</span><strong>时间:</strong><span>" + order.createDate  + "</span><input type='button' class='cancel-order btn btn-xs' value='取消订单' /><i class='openBtn'><span class='glyphicon glyphicon-chevron-up' aria-hidden='true'></span></i></div><table class='table productTable'>"  + productHtml  + "</table><div class='order-buttom text-right'><strong>总价:</strong><span>¥&nbsp;" + order.total  + "</span><strong>佣金:</strong><span>¥&nbsp;" + order.profitsStr  + "</span></div></div>" }); $(".order-info").html(orderHtml); }, error:function(){ $(".order-info").html("加载失败!!!").css({"font-size":"20px","color":"red"}).addClass("text-center"); } });};
查看完整描述

2 回答

已采纳
?
leiqjl

TA贡献3条经验 获得超0个赞

type:"get"前端Ajax发送的是get请求,而你后端@DeleteMapping对应的是delete请求,你把type改成delete试试

查看完整回答
反对 回复 2017-09-25
?
褪去浮尘

TA贡献10条经验 获得超0个赞

deleteMapping改成requestMapping

查看完整回答
反对 回复 2017-09-25
  • 2 回答
  • 0 关注
  • 2240 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信