LoginSignup
0
0

More than 3 years have passed since last update.

Thymeleafで三項演算子を使って画像を表示する方法

Last updated at Posted at 2019-12-03

Thymeleafで三項演算子を使い、画像を表示する方法を自分用メモで残します。

<p th:utext="${zahyou eq 1}?'<img src=&quot;./ship.png&quot;/>':' '></p>"

↑例

三項演算子が

th:utext"${条件式}?'A':'B'"

中に画像を埋め込むのが
&quot; html内の二重引用符をエスケープするためのものです。

utextプレーンテキストを「<a href ..」として印刷しないようにthymeleafに指示する

参考記事

三項演算子
画像表示

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0