繁体   English   中英

如何在 Thymeleaf 和 Spring Boot 中显示两行不同的内容?

[英]How to display the contents of <td> in two different lines in Thymeleaf and Spring Boot?

我有一个基于Spring Boot的应用程序,它以表格格式显示一些数据。

我想在两条不同的行上但在同一<td>内显示一些值。 像这样的东西。

Mule: Down
TC: Down

服务器服务.java

public String getServerStatus(String kdn, String hostname, String serverType) {
        String muleStatus = getMuleStatus(hostname, MULE_DEV_STATUS_SSH_CMD);
        String tcStatus = getTCStatus(hostname);
        serverStatus = muleStatus + "<br/>" + tcStatus;
        return serverStatus;
  }

从上面提到的服务 class 中,我改变了我的逻辑返回一个看起来像这样的StringTC: Down <br/> Mule: Down ,希望浏览器会自动解析这个HTML标签并将内容显示在两个不同的行在同一列中。 但这没有用。

因此,我在server.html文件中添加了<td th:text="${#strings.escapeXml(appDeploy.server.status)}">001</td>但这也没有帮助,在我看到的浏览器中像这样的东西。

Mule: DOWN&lt;br/&gt;TC: DOWN

不知道还缺少什么。

如果你的目的只是让它在 Thymeleaf 中分成两行,你应该将 th:text 更改为 th:utext。

<td th:text="${appDeploy.server.status}"></td>

像:

<td th:utext="${appDeploy.server.status}"></td>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM