Java ThymileAF-不带标记的输出变量
我使用Thymeleaf作为模板引擎,通常输出如下的变量值: 在Java I集合中:Java ThymileAF-不带标记的输出变量,java,thymeleaf,Java,Thymeleaf,我使用Thymeleaf作为模板引擎,通常输出如下的变量值: 在Java I集合中: ctx.setVariable("tester", "hello"); 在html模板中,我输出: <span th:text="${tester}"></span> 不幸的是,它不起作用。我的目标是避免不必要的标记来输出变量值。这可能与Thymeleaf有关吗?Thymeleaf在th:标记上触发,据我所知,这是唯一的方法。 您描述的行为适用于JSF 致意 BenThymeleaf
ctx.setVariable("tester", "hello");
在html模板中,我输出:
<span th:text="${tester}"></span>
不幸的是,它不起作用。我的目标是避免不必要的标记来输出变量值。这可能与Thymeleaf有关吗?Thymeleaf在th:标记上触发,据我所知,这是唯一的方法。 您描述的行为适用于JSF 致意
BenThymeleaf在th:tag上触发,据我所知,这是唯一的方法。 您描述的行为适用于JSF 致意 Ben我的目标是避免不必要的标记来输出变量值。这可以用百里香吗 是的,这是可能的。您可以使用Thymeleaf合成th:block标记,请参见 示例模板摘录:
<body>
<th:block th:text="${tester}"></th:block>
</body>
这将呈现以下HTML:
<body>
hello
</body>
只显示变量。我的目标是避免不必要的标记来输出变量值。这可以用百里香吗
是的,这是可能的。您可以使用Thymeleaf合成th:block标记,请参见
示例模板摘录:
<body>
<th:block th:text="${tester}"></th:block>
</body>
这将呈现以下HTML:
<body>
hello
</body>
只显示变量。我还设法找到了一些解决方法:
<span th:text="${tester}" th:remove="tag"></span>
th:remove删除span标记,但保留内容。我还设法找到了一些解决方法:
<span th:text="${tester}" th:remove="tag"></span>
th:remove删除跨度标记,但保留内容