Spring security can';t在Spring 4中执行CSRF

Spring security can';t在Spring 4中执行CSRF,spring-security,csrf,Spring Security,Csrf,我在Spring 4的xml文件中启用了CSRF: <http auto-config="true" use-expressions="true"> ... <csrf /> </http> 我错过了什么 编辑: 我发现CSRF可以使用默认的登录页面 问题在于登录页面名称。我的名字是“登录”,但Spring Security没有在其中添加CSRF标记((不知道为什么。但如果我在重定向后将“/login”放在登录页上,则一切正常。本教程对我帮助

我在Spring 4的xml文件中启用了CSRF:

<http auto-config="true" use-expressions="true">
    ...
    <csrf />
</http>
我错过了什么

编辑:
我发现CSRF可以使用默认的登录页面

问题在于登录页面名称。我的名字是“登录”,但Spring Security没有在其中添加CSRF标记((不知道为什么。但如果我在重定向后将“/login”放在登录页上,则一切正常。本教程对我帮助很大:


我希望您添加了Spring security jsp标记,`不。但我不在我的页面上使用它。请将它添加到您的jsp中,并为您禁用安全性的资源添加它。这应该可以解决您的问题。如果需要,请告诉我。但我不想禁用任何东西。我只想激活CSRF。我不明白为什么需要sec标记(((
<form name='form' action="<c:url value='/login' />"  method='post'>

          <table>  
           <tr>  
            <td>User:</td>  
            <td><input type='text' style="width:100%" name='username' value=''>
            </td>  
           </tr>  
           <tr>  
            <td>Password:</td>  
            <td><input type='password' style="width:100%" name='password' />  
            </td>  
           </tr>  
           <tr>  
            <td colspan='2'><input name="submit"  type="submit" value="TryMe)" />
            </td>  
           </tr>  
           <tr>  
            <td colspan='2'><input name="reset" type="reset" />  
            </td>  
           </tr>
          </table>
            <input type="text" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
Expected CSRF token not found. Has your session expired?