spring security的csrf防御功能:
在jsp中使用如下代码:
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags' %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
<head>
<sec:csrfMetaTags/>
</head>
<body>
<form:form>
<table id="user" action="" method="post">
...
</table>
</form:form>
</body>
</html>上述代码中,
<sec:csrfMetaTags/>等同于:
<head><meta name="_csrf" content="${_csrf.token}"/><meta name="_csrf_header" content="${_csrf.headerName}"/></head>
而,之所以使用spring的<form:form>替代<form>标签,是因为spring的<form:form>标签可以自动将token以hidden类型添加到提交的数据当中
在js代码中,使用如下方式:var csrfParameter = $("meta[name='_csrf_parame

最低0.47元/天 解锁文章
1786





