thymeleafで属性を追加しよう

今回は、thymeleafを使っている時属性を追加する方法についてみていきたいと思います。

th:attrappend

th:attrappend="属性名=${データ}"
  • 属性を追加するには「th:attrappend」を使います。

サンプル

いくつかのサンプルを見てみましょう。

th:attrappend="aria-valuenow=${percent}"
th:attrappend="aria-valuemin=${percentMin}"
th:attrappend="class=${' ' + cssStyle}"

コメントを残す