以下の例では、架空のAnimalViewDtoクラスに保持した値をHTMLに出力させている。
AnimalViewDtoクラス
package jp.type.user.controller.index.view.dto
/**
* 動物紹介ページ用ViewDto
*/
data class AnimalViewDto(
/** ID */
val id: Int,
/** 動物名 */
val name: String,
/** 性別*/
val sex: String,
)
文字列の出力方法
<p th:text="この動物の名前は、|${animalViewDto.name}|です。"></p>
<p th:text="この動物の名前は、" + ${animalViewDto.name} + "です。"></p>
<p>この動物の名前は、[[${animalViewDto.name}]]です。]]</p>
文字列の出力方法は上記の3つ。
状況に応じて使い分ける。