18
Jan 2015
by
佐々木 亜里沙
@の後ろにBean名をつけることで、そのBeanにアクセスすることができます。
*ThymeleafでSpringのpropertyファイル(application.propertiesなど)に記述している変数を利用したい場合
${@environment.getProperty('property.key')}
*環境ごとに表示を変更したい場合
<div th:if=${@environment.acceptsProfiles('production')}>
This is the production profile
</div>
or
<div th:if="${#arrays.contains(@environment.getActiveProfiles(),'production')}">
This is the production profile
</div>
という形で利用できます。
ちなみにシステム環境変数を利用する場合は、以下のように書けるようです。
${@systemProperties['property.key']}
