Ajax POST results in a 405 (Method Not Allowed) - Spring MVC

前端 未结 3 383
离开以前
离开以前 2020-12-18 06:16

I\'m trying to make an ajax call to my Spring controller/action with POST method, and return an object from the server with @ResponseBody. The strange situation is that it s

3条回答
  •  一整个雨季
    2020-12-18 06:29

    In my case, with same problem, helps this:

    • add taglib:
     <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
    
    • add in jsp body:
    
    
    • add in ajax
    headers: {"X-CSRF-TOKEN": $("meta[name='_csrf']").attr("content")}
    

    P.S. Thanks to Illya Shulgin, cool ansver, now it here.

提交回复
热议问题