Thymeleaf th:text - 放置文本而不删除 HTML 结构 [英] Thymeleaf th:text - Put a text without removing HTML structures

查看:54
本文介绍了Thymeleaf th:text - 放置文本而不删除 HTML 结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 thymeleaf 的新手,我尝试创建一个模板.我的问题是这段代码:

I'm new in thymeleaf and I try to create a template. My problem is this code:

代码

<h1 th:text="${header.title}" >
   title
   <small th:text="${header.subtitle}" >Subtitle</small>
</h1>

我想得到这个输出:

<h1> TITLE <small> SUBTITLE</small> </h1>

但这是真正的输出:

<h1> TITLE </h1>

如何才能不删除小"中的内容?

How can I do so it doesn't remove what is inside of "small"?

推荐答案

我遇到了同样的问题.答案是th:inline='text'

I faced the same problem. The answer is th:inline='text'

这应该可以解决您的问题

This should solve your issue

<h1 th:inline="text" >
   [[${header.title}]]
   <small th:text="${header.subtitle}">Subtitle</small>
</h1>


或者你也可以使用 th:remove="tag"

<h1>
    <span th:text="${header.title}" th:remove="tag">title</span>
    <small th:text="${header.subtitle}" >Subtitle</small>
</h1>

这篇关于Thymeleaf th:text - 放置文本而不删除 HTML 结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆