一般社団法人 全国個人事業主支援協会

COLUMN コラム

  • Thymeleaf その2

th属性について。

htmlの特定の属性のプレフィックスにつき、動的なコンテンツが生成可能となる。

◯th:text
th:text属性は、指定した変数の値でHTML要素のテキストコンテンツを置き換えます。

例:

<p th:text=”${user.name}”>User Name</p>
このコードでは、user.nameの値が<p>タグの中に表示されます。

◯th:if / th:unless
th:if属性は、指定した条件が真の場合に要素を表示し、th:unless属性は条件が偽の場合に要素を表示します。例:

<p th:if=”${user.loggedIn}”>Welcome, <span th:text=”${user.name}”>User</span>!</p>
<p th:unless=”${user.loggedIn}”>Please log in.</p

The following two tabs change content below.

S, M

最新記事 by S, M (全て見る)

この記事をシェアする

  • Twitterでシェア
  • Facebookでシェア
  • LINEでシェア