且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

不允许使用HTTP 405-Spring Boot + Spring Security

更新时间:2022-06-09 00:03:19

您忘记了csrf-令牌.

建议您在meta-tag中添加csrf-Token.您可以在

It's recommended that you add the csrf-Token in the meta-tag. You can read it in the Spring Security Documentation

您可以执行以下操作:

$(function () {
  var token = $("meta[name='_csrf']").attr("content");
  var header = $("meta[name='_csrf_header']").attr("content");
  $(document).ajaxSend(function(e, xhr, options) {
    xhr.setRequestHeader(header, token);
  });
});