首页 > 解决方案 > Kotlin +spring boot post请求默认布尔值

问题描述

目前我正在使用 Kotlin 开发 Spring Boot Restful Web 应用程序。我想在 post 请求的正文中添加一个布尔标志,如果未传入,则其默认值为 true

DTO:

data class PersonDTO(

    @field:NotNull
    val name: String,

    val enabledProfile: Boolean = true // setting this to true is not working
)

默认情况下如何将标志设置enabledProfile为true?

标签: restspring-bootkotlinboolean

解决方案


推荐阅读