You can create a mapping in Spring MVC that receives the CSRF token:
@RequestMapping(value="/csrf-token", method=RequestMethod.GET) public @ResponseBody String getCsrfToken(HttpServletRequest request) { CsrfToken token = (CsrfToken)request.getAttribute(CsrfToken.class.getName()); return token.getToken(); }
source share