--------------------
메타 태그에 값 추가
--------------------
<meta name="_csrf" content="${_csrf.token}"/>
<meta name="_csrf_header" content="${_csrf.headerName}"/>



--------------------
스크립트
--------------------
var token = $("meta[name='_csrf']").attr("content");
var header = $("meta[name='_csrf_header']").attr("content");


$.ajax({
        ...
        beforeSend: function(xhr) {
            xhr.setRequestHeader(header, token);
        },
        ...




참고:
http://docs.spring.io/spring-security/site/docs/3.2.0.CI-SNAPSHOT/reference/html/csrf.html#csrf-include-csrf-token-ajax

+ Recent posts