【发布时间】:2016-09-19 21:43:51
【问题描述】:
我在将 csrf 添加到 ajax 请求时遇到问题。我在客户端使用带有 spring-boot/spring 安全性的 thymeleaf。 Spring security 不允许该请求,因为缺少 csrf-token。这是我的ajax代码
function bits(){
var xhttp = new XMLHttpRequest();
var selected = document.getElementById("product").value;
xhttp.onreadystatechange = function(){
if(xhttp.readyState==4 && xhttp.status==200){
var result= JSON.parse(xhttp.responseText)
var length = result.length;
for(i=0; i<length; i++){
console.log(result[k].spid);
}
}
};
xhttp.open("POST", "http://localhost:8080/bids?q="+selected, true);
xhttp.send();
}
我们将不胜感激
【问题讨论】:
标签: ajax spring spring-security thymeleaf