【发布时间】:2014-09-08 00:17:32
【问题描述】:
我正在使用 spring boot(版本 1.1.1.RELEASE)并尝试在 html 模板中添加字符串模型属性。
控制器:
@RequestMapping({"/", ""})
public String template(Model model) {
model.addAttribute("coolStuff", coolStuff);
return "panel/index";
}
HTML 模板:
<script type="text/javascript" th:inline="text">
/*<![CDATA[*/
[[${coolStuff}]]
/*]]>*/
</script>
thymeleaf 的 th:inline 在“文本”模式下工作得很好,但现在它正在向提供的字符串添加 HTML 编码(转义字符)。 th:inline in mode "javascript" 转义双引号,因此这也不起作用。 有没有什么方法可以在不编码的情况下将模型属性中的字符串放入 html 模板中?
【问题讨论】:
标签: spring-boot thymeleaf html-encode modelattribute