私はSpring Securityを数日間実装しようとしており、csrf tokens
.
デバッグしたCsrfRequestDataValueProcessor
ところ、次の行が null を返していることがわかりました。
CsrfToken token = (CsrfToken) request.getAttribute(CsrfToken.class.getName());
Thymeleaf を使用すると、次の形式になります。
<form th:action="@{/j_spring_security_check}" method="post">
<label for="j_username">Username</label>:
<input type="text" id="j_username" name="j_username" /> <br />
<label for="j_password">Password</label>:
<input type="password" id="j_password" name="j_password" /> <br />
<input type="submit" value="Log in" />
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}" />
</form>
レンダリングされず、次の例外がスローされます。
リクエストの処理に失敗しました。ネストされた例外は org.thymeleaf.exceptions.TemplateProcessingException: Exception Evaluation SpringEL expression: "_csrf.parameterName" (loginsample:19)] で根本原因 org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos 0): Property or field 'parameterName' が null で見つかりません
これはなぜでしょうか?