0
0

KotlinとThymeleaf 基本編(Dtoの値を出力)

Posted at
以下の例では、架空の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つ。
状況に応じて使い分ける。

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