我正试图向javaspring发送一个删除请求。问题是我总是收到一条403禁止的响应消息。
这是客户端的javascript代码:
$(".deleteList").click(function(){
var url = "boodschappenlijstjes.htm/" + this.id;
console.log(url);
$.ajax(url, {
method: "DELETE",
success: function(){
console.log("gelukt");
}
});
});
我试图访问的控制器方法:
@RequestMapping(value = "/boodschappenlijstjes/{id}", method = RequestMethod.DELETE)
public ResponseEntity verwijderLijstje(Principal principal, @PathVariable(value="id") int id)
{
//some code
}
我也在使用弹簧安全:
<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>
我希望有人能帮我…
Thx
$.ajax({
url: url,
method: "DELETE",
success: function(){
console.log("gelukt");
}
});
我找到了解决方案:我不得不将javascript文件中的url更改为:
"boodschappenlijstjes/" + this.id + ".htm"