Tag: 百里香

在Spring Boot 2中解开Thymeleaf中的Kotlin HashMap

我有一个Kotlin函数,它创建一个带有hashmap的模型,如下所示 @GetMapping(“/”) fun index(model: Model): Mono { model.addAttribute(“images”, imageService.findAllImages()?.flatMap { image -> Mono.just(image) .zipWith(repository.findByImageId(image?.id!!).collectList()) .map({ imageAndComments: Tuple2<Image?, MutableList> -> hashMapOf( “id” to imageAndComments.t1?.id, “name” to imageAndComments.t1?.name, “comments” to imageAndComments.t2) }).log(“findAllImages”) }) model.addAttribute(“extra”, “DevTools can also detech code changes.”) return Mono.just(“index”) } Image.kt package learningspringboot.images import org.springframework.data.annotation.Id data class Image(@Id var id: String? = null, var […]