Deprecated: implode(): Passing glue string after array is deprecated. Swap the parameters in /home/hide-tono/tono-n-chi.com/public_html/blog/wp-content/themes/simplicity2/functions.php on line 376
Spring MVC + Spring Security + thymeleafでフォームに自動で_csrfが付かない

Spring MVC + Spring Security + thymeleafでフォームに自動で_csrfが付かない

スポンサーリンク

実際にはajaxでフォーム内のデータをやりとりするしょりで、
HTMLの実装を以下のように記述していました。
(AMPで怒られるのでformをf0rmと表記しています)

<f0rm id="form_xxx" role="form" th:object="${authData}" action="#" method="post">
    <!-- フォームの内容 -->
</form>

本来ならこのフォームにSpring Securityのhidden input(id=”_csrf”)がつくはずなのですが、付かない。

色々検証したところ、thymeleaf使用時には以下のようにthymeleafのactionを設定してあげなければいけませんでした。

<f0rm id="form_xxx" role="form" th:action="@{#}" th:object="${authData}" action="#" method="post">
    <!-- フォームの内容 -->
</form>

そんだけ。

スポンサーリンク







シェアする

  • このエントリーをはてなブックマークに追加

フォローする

スポンサーリンク