gpt4 book ai didi

java - java spring 禁止的 Ajax 删除请求

转载 作者:太空宇宙 更新时间:2023-11-04 15:20:22 24 4
gpt4 key购买 nike

我正在尝试向 java spring 发送删除请求。问题是我总是收到 403 禁止响应消息。

这是客户端 JavaScript 代码:

$(".deleteList").click(function(){
var url = "boodschappenlijstjes.htm/" + this.id;
console.log(url);
$.ajax(url, {
method: "DELETE",
success: function(){
console.log("gelukt");
}
});
});

我尝试访问的 Controller 方法:

    @RequestMapping(value = "/boodschappenlijstjes/{id}", method = RequestMethod.DELETE)
public ResponseEntity verwijderLijstje(Principal principal, @PathVariable(value="id") int id)
{
//some code
}

我也在使用 Spring Security:

    <http auto-config = "true">
<intercept-url pattern='/overzicht*' access='ROLE_USER' />
<intercept-url pattern='/klant*' access='ROLE_USER' />
<intercept-url pattern='/boodschappenlijstjes*' access='ROLE_USER' />
<form-login login-page="/login.htm"
default-target-url="/overzicht.htm"
authentication-failure-url="/loginfailed.htm" />
<logout logout-success-url="/logout.htm" />
</http>

希望有人能帮助我...

谢谢

最佳答案

$.ajax({
url: url,
method: "DELETE",
success: function(){
console.log("gelukt");
}
});

关于java - java spring 禁止的 Ajax 删除请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20460660/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com