锚文本 URL 未在 th:text thymleaf 中显示为链接



我将一些文本转换为显示为链接,它来自后端正确,但在 UI 中它不显示为链接。 我正在使用百里香素来渲染 p 标签内的文本。请在下面找到代码:

html 文件:

<div class="column" style="margin-left: auto; margin-right: auto; float: none;" th:each="pre:${prrMap}"> 
<div class="prerequisite" align="center">
<label class="prerequisite" th:text="${pre.key}"></label>
<p class="prerequisite" id="prerequisite" th:text=${pre.value}></p>
</div>
</div>

th:text=${pre.value}包含具有锚文本的字符串。

示例:${pre.value} = "先决条件:测试数据 {a href="https://ecom-test-data.index.html"}测试链接 {/a} 链接已创建 数据但不显示为链接">

我不能在这里包含锚文本标签,所以使用了{} = <>,它在前端显示。

例外输出:先决条件:测试数据测试链路 已创建数据但不显示为链接

如果您希望输出未转义的 html,请使用th:utext(而不是th:text(。

最新更新