首页 > 解决方案 > 执行 Thymeleaf :从变量插入

问题描述

我找不到从 Thymeleaf 中的模型字符串显示以下 html 内容的解决方案:

<div layout:insert="~{components/component :: component(parameter)}"></div>

我在 Kotlin 中通过以下方式设置了 html 字符串:

model["component"] =
  "<div layout:insert=\"~{components/component :: component(parameter)}\"></div>".replace('\"', '"')

我希望将变量内容显示为字符串并执行它以显示组件外观,但我只能让字符串部分与 https://stackoverflow.com/a/64805372/1383108中的想法一起工作:

[[${component}]]

我已经尝试过[(${component})]和组合__${}来启用预处理,但一切都没有成功,所以我希望有一些新的想法。它在检查器中显示为 html,但未处理 Thymeleaf 部分。

标签: htmlspring-bootthymeleaf

解决方案


推荐阅读